예제 #1
0
        public void ServerConfigurationNullTest()
        {
            TestGraphicalUserInterface _tg  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tg, "", "", "");

            Assert.IsFalse(_tg.WarningCalled);
        }
예제 #2
0
        public void EmptyServerDescriptorTest()
        {
            TestGraphicalUserInterface _ui  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_ui, string.Empty, string.Empty, string.Empty);

            Assert.IsFalse(_ui.WarningCalled);
        }
예제 #3
0
        public void ServerConfigurationWrongAssemblyTest()
        {
            TestGraphicalUserInterface _tgi = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tgi, "wrong_path", "wrong.codebase", "wrong.configuration");

            Assert.IsTrue(_tgi.WarningCalled);
            Assert.IsTrue(_tgi.WarningMessage.Contains("wrong.codebase"));
            Assert.AreEqual <string>("Open configuration editor", _tgi.WarningCaption);
        }
예제 #4
0
        public void ServerSelectorCreatorTest()
        {
            TestGraphicalUserInterface _tg  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tg, "", "", "");

            Assert.IsNull(_nss.SelectedAssembly);
            Assert.IsNull(_nss.ServerConfiguration);
            Assert.IsNull(_nss.IServerConfiguration);
        }
예제 #5
0
        public void EmptyServerDescriptorTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.BaseDirectory).Returns(string.Empty);
            TestGraphicalUserInterface _ui  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_ui, _directory.Object, string.Empty, string.Empty);

            Assert.IsFalse(_ui.WarningCalled);
        }
예제 #6
0
        public void ServerConfigurationNullTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.BaseDirectory).Returns(@"C:\");
            TestGraphicalUserInterface _tg  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tg, _directory.Object, "", "");

            Assert.IsFalse(_tg.WarningCalled);
        }
예제 #7
0
        public void ServerConfigurationWrongAssemblyTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.BaseDirectory).Returns(@"wrong_path");
            TestGraphicalUserInterface _tgi = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tgi, _directory.Object, "wrong.codebase", "wrong.configuration");

            Assert.IsTrue(_tgi.WarningCalled);
            Assert.IsTrue(_tgi.WarningMessage.Contains("wrong.codebase"));
            Assert.AreEqual <string>("Open configuration editor", _tgi.WarningCaption);
        }
예제 #8
0
        public void ServerSelectorCreatorTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.BaseDirectory).Returns(@"C:\");
            TestGraphicalUserInterface _tg  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tg, _directory.Object, "", "");

            Assert.IsNull(_nss.SelectedAssembly);
            Assert.IsNull(_nss.ServerConfiguration);
            Assert.IsNull(_nss.IServerConfiguration);
        }
예제 #9
0
        public void ServerConfigurationWTest()
        {
            TestGraphicalUserInterface _ui  = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_ui, "wrong_path", "CAS.CommServer.UA.ConfigurationEditor.ServerConfiguration.dll", "");

            Assert.AreEqual <int>(2, _ui.ExclamationCallCount);
            Assert.AreEqual <int>(0, _ui.ErrorCallCount);
            Assert.AreEqual <int>(0, _ui.OpenFileDialog4UnitTestAssertErrors);
            CollectionAssert.AreEqual(new string[] { }, _ui.ErrorCaption);
            CollectionAssert.AreEqual(new string[] { }, _ui.ErrorMessage);
            CollectionAssert.AreEqual(new string[] { "No configuration file has been selected!", "No folder is selected" }, _ui.ExclamationCaption);
            CollectionAssert.AreEqual(new string[] { "You did not choose the configuration file. Please select a location of the default configuration file.",
                                                     "Folder is not selected, configuration will be created in the default location." }, _ui.ExclamationMessage);
        }
예제 #10
0
        public void ConstructorWrongAssemblyTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.DefaultDirectory).Returns(Directory.GetCurrentDirectory());
            TestGraphicalUserInterface _tgi = new TestGraphicalUserInterface();
            ServerSelector             _nss = new ServerSelector(_tgi, _directory.Object, "wrong.codebase", "wrong.configuration");

            //_nss
            Assert.IsNull(_nss.IServerConfiguration);
            Assert.IsNull(_nss.SelectedAssembly);
            Assert.IsNull(_nss.ServerConfiguration);
            //_tgi
            Assert.IsTrue(_tgi.WarningCalled);
            Assert.IsTrue(_tgi.WarningMessage.Contains("wrong.codebase"));
            Assert.AreEqual <string>("Open configuration editor", _tgi.WarningCaption);
        }
예제 #11
0
        public void PluginOkWrongConfigurationTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();

            _directory.SetupGet(x => x.DefaultDirectory).Returns(Directory.GetCurrentDirectory());
            TestGraphicalUserInterface _tgi           = new TestGraphicalUserInterface();
            ServerSelector             _underTestItem = new ServerSelector(_tgi, _directory.Object, m_PluginFullPath, "");
            //_underTestItem
            int  _configurationChanged = 0;
            bool _configuration        = false;;

            _underTestItem.OnConfigurationChanged += (x, y) => { _configurationChanged++; _configuration = y.ConfigurationFileChanged; };
            Assert.IsNotNull(_underTestItem.IServerConfiguration);
            Assert.IsFalse(String.IsNullOrEmpty(_underTestItem.IServerConfiguration.DefaultFileName));
            Assert.AreEqual <string>("CAS.UAServer.Configuration.uasconfig", _underTestItem.IServerConfiguration.DefaultFileName);
            Assert.IsNotNull(_underTestItem.SelectedAssembly);
            Assert.IsNotNull(_underTestItem.SelectedAssembly.Configuration);
            Assert.IsNotNull(_underTestItem.ServerConfiguration);
            Assert.AreEqual <string>(m_PluginFullPath, _underTestItem.ServerConfiguration.Codebase);
            Assert.AreEqual <string>(Path.Combine(Directory.GetCurrentDirectory(), _underTestItem.IServerConfiguration.DefaultFileName), _underTestItem.ServerConfiguration.Configuration);
            Assert.AreEqual <int>(0, _configurationChanged);
            Assert.IsFalse(_configuration);
            _underTestItem.IServerConfiguration.CreateDefaultConfiguration();
            Assert.AreEqual <int>(2, _configurationChanged);
            Assert.IsTrue(_configuration);
            _underTestItem.IServerConfiguration.CreateDefaultConfiguration();
            Assert.AreEqual <int>(4, _configurationChanged);
            Assert.IsTrue(_configuration);

            //_tgi
            Assert.AreEqual <int>(2, _tgi.ExclamationCallCount);
            Assert.AreEqual <int>(0, _tgi.ErrorCallCount);
            Assert.AreEqual <int>(0, _tgi.OpenFileDialog4UnitTestAssertErrors);
            CollectionAssert.AreEqual(new string[] { }, _tgi.ErrorCaption);
            CollectionAssert.AreEqual(new string[] { }, _tgi.ErrorMessage);
            CollectionAssert.AreEqual(new string[] { "No configuration file has been selected!", "No folder is selected" }, _tgi.ExclamationCaption);
            CollectionAssert.AreEqual(new string[] { "You did not choose the configuration file. Please select a location of the default configuration file.",
                                                     "Folder is not selected, configuration will be created in the default location." }, _tgi.ExclamationMessage);
        }