miniSql

创建
zgc123@gmail.com authored at 11/19/2023 1:40:15 AM
6136600
Tree
0 Parent(s)
Summary: 1 changed files with 80 additions and 0 deletions.
Added +80 -0
Added +80 -0
diff --git a/minisqlquery-master/src/MiniSqlQuery.Tests/MRU/MostRecentFilesService_Tests.cs b/minisqlquery-master/src/MiniSqlQuery.Tests/MRU/MostRecentFilesService_Tests.cs
new file mode 100644
index 0000000..0849ab6
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery.Tests/MRU/MostRecentFilesService_Tests.cs
@@ -0,0 +1,80 @@
+#region License
+// Copyright 2005-2019 Paul Kohler (https://github.com/paulkohler/minisqlquery). All rights reserved.
+// This source code is made available under the terms of the GNU Lesser General Public License v3.0
+// https://github.com/paulkohler/minisqlquery/blob/master/LICENSE
+#endregion
+
+using MiniSqlQuery.Core;
+using NUnit.Framework;
+
+// ReSharper disable InconsistentNaming
+
+namespace MiniSqlQuery.Tests.MRU
+{
+    [TestFixture]
+    public class MostRecentFilesService_Tests
+    {
+        private MostRecentFilesService _service;
+
+        [Test]
+        public void List_does_not_exceed_maximum_entries()
+        {
+            // set up the max entries
+            int i = 1;
+            for (; i <= _service.MaxCommands; i++)
+            {
+                _service.Register(i.ToString());
+            }
+
+            // add 1 extra
+            i++;
+            _service.Register(i.ToString());
+
+            Assert.That(_service.Filenames.Count, Is.EqualTo(_service.MaxCommands));
+        }
+
+        [Test]
+        public void No_filenames_at_start()
+        {
+            Assert.That(_service.Filenames.Count, Is.EqualTo(0));
+        }
+
+        [Test]
+        public void Register_adds_new_files()
+        {
+            _service.Register("1");
+            _service.Register("2");
+            Assert.That(_service.Filenames.Count, Is.EqualTo(2));
+        }
+
+        [Test]
+        public void Register_adds_only_new_files()
+        {
+            _service.Register("1");
+            _service.Register("2");
+            _service.Register("2");
+            _service.Register("2");
+            Assert.That(_service.Filenames.Count, Is.EqualTo(2));
+        }
+
+        [Test]
+        public void Register_takes_off_relevent_file()
+        {
+            _service.Register("1");
+            _service.Register("2");
+            _service.Register("3");
+            Assert.That(_service.Filenames.Count, Is.EqualTo(3));
+
+            _service.Remove("2");
+            Assert.That(_service.Filenames.Count, Is.EqualTo(2));
+            Assert.That(_service.Filenames[0], Is.EqualTo("3"));
+            Assert.That(_service.Filenames[1], Is.EqualTo("1"));
+        }
+
+        [SetUp]
+        public void TestSetUp()
+        {
+            _service = new MostRecentFilesService();
+        }
+    }
+}
\ No newline at end of file