miniSql

创建
zgc123@gmail.com authored at 11/19/2023 1:40:15 AM
6136600
Tree
0 Parent(s)
Summary: 2 changed files with 134 additions and 0 deletions.
Added +80 -0
Added +54 -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
Added +54 -0
diff --git a/minisqlquery-master/src/MiniSqlQuery.Tests/MRU/OpenRecentFileCommand_Tests.cs b/minisqlquery-master/src/MiniSqlQuery.Tests/MRU/OpenRecentFileCommand_Tests.cs
new file mode 100644
index 0000000..56ead9a
--- /dev/null
+++ b/minisqlquery-master/src/MiniSqlQuery.Tests/MRU/OpenRecentFileCommand_Tests.cs
@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+using MiniSqlQuery.Commands;
+using MiniSqlQuery.Core;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+// ReSharper disable InconsistentNaming
+
+namespace MiniSqlQuery.Tests.MRU
+{
+    [TestFixture]
+    public class OpenRecentFileCommand_Tests
+    {
+        private IMostRecentFilesService _service;
+
+        [Test]
+        public void If_File_in_slot_1_the_command_is_enabled()
+        {
+            _service.Expect(s => s.Filenames).Return(new List<string> { "File1" });
+
+            var cmd = new OpenRecentFileCommand(_service, 1);
+
+            Assert.That(cmd.Enabled, Is.True);
+            _service.VerifyAllExpectations();
+        }
+
+        [Test]
+        public void If_no_Files_the_command_is_disabled()
+        {
+            _service.Expect(s => s.Filenames).Return(new List<string>());
+
+            var cmd = new OpenRecentFileCommand(_service, 1);
+
+            Assert.That(cmd.Enabled, Is.False);
+        }
+
+        [SetUp]
+        public void TestSetUp()
+        {
+            _service = MockRepository.GenerateMock<IMostRecentFilesService>();
+        }
+
+        [Test]
+        public void The_name_is_updated()
+        {
+            _service.Expect(s => s.Filenames).Return(new List<string> { "File1", "File2" });
+
+            var cmd = new OpenRecentFileCommand(_service, 1);
+            cmd.UpdateName();
+
+            Assert.That(cmd.Name, Is.EqualTo("&1 - File1"));
+        }
+    }
+}
\ No newline at end of file