public void ReadSaveConfigurationDataWrapperTest()
        {
            UANetworkingConfigurationConfigurationDataWrapper _newConfiguration = new UANetworkingConfigurationConfigurationDataWrapper();

            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnLoadedCount);
            bool     _ConfigurationFileChanged = false;
            FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataWrapper.xml");

            Assert.IsFalse(_configFile.Exists);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnSavingCount);
            _newConfiguration.SaveConfiguration(_configFile);

            //on SaveConfiguration tests
            Assert.AreEqual <int>(1, _newConfiguration.CurrentConfiguration.OnSavingCount);
            Assert.IsFalse(_ConfigurationFileChanged);
            Assert.IsNotNull(_newConfiguration.CurrentConfiguration);
            _configFile.Refresh();
            Assert.IsTrue(_configFile.Exists);
            Assert.IsNotNull(_newConfiguration.ConfigurationData);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnLoadedCount);

            //prepare ReadConfiguration
            _newConfiguration.OnModified += (x, y) => { _ConfigurationFileChanged = true; };
            _newConfiguration.ReadConfiguration(_configFile);

            //on ReadConfiguration test
            Assert.IsTrue(_ConfigurationFileChanged);
            Assert.IsNotNull(_newConfiguration.CurrentConfiguration);
            Assert.IsNotNull(_newConfiguration.ConfigurationData);
            Assert.AreEqual <int>(1, _newConfiguration.CurrentConfiguration.OnLoadedCount);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnSavingCount);
        }
        public void ConfigurationDataNullTest()
        {
            UANetworkingConfigurationConfigurationDataWrapper _newConfiguration = new UANetworkingConfigurationConfigurationDataWrapper();

            _newConfiguration.CurrentConfiguration.ConfigurationData = null;
            FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataWrapper.ConfigurationDataNull.xml");

            Assert.IsFalse(_configFile.Exists);
            _newConfiguration.SaveConfiguration(_configFile);
        }
Example #3
0
        public void ConfigurationDataNullTest()
        {
            Logger _Logger = new Logger();

            CommonServiceLocator.ServiceLocator.SetLocatorProvider(() => new Container(new object[] { _Logger }));
            UANetworkingConfigurationConfigurationDataWrapper _newConfiguration = new UANetworkingConfigurationConfigurationDataWrapper();

            _newConfiguration.CurrentConfiguration.ConfigurationData = null;
            FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataWrapper.ConfigurationDataNull.xml");

            Assert.IsFalse(_configFile.Exists);
            _newConfiguration.SaveConfiguration(_configFile);
        }
Example #4
0
        public void ReadSaveConfigurationDataWrapperTest()
        {
            Logger _Logger = new Logger();

            CommonServiceLocator.ServiceLocator.SetLocatorProvider(() => new Container(new object[] { _Logger }));
            UANetworkingConfigurationConfigurationDataWrapper _newConfiguration = new UANetworkingConfigurationConfigurationDataWrapper();

            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnLoadedCount);
            FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataWrapper.xml");

            Assert.IsFalse(_configFile.Exists);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnSavingCount);
            _newConfiguration.SaveConfiguration(_configFile);

            //on SaveConfiguration tests
            Assert.AreEqual <int>(1, _newConfiguration.CurrentConfiguration.OnSavingCount);
            Assert.IsNotNull(_newConfiguration.CurrentConfiguration);
            _configFile.Refresh();
            Assert.IsTrue(_configFile.Exists);
            Assert.IsNotNull(_newConfiguration.ConfigurationData);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnLoadedCount);

            //prepare ReadConfiguration
            bool _ConfigurationFileChanged = false;

            _newConfiguration.OnModified += (x, y) => { _ConfigurationFileChanged = true; };
            _newConfiguration.ReadConfiguration(_configFile);

            //on ReadConfiguration test
            Assert.IsTrue(_ConfigurationFileChanged);
            Assert.IsNotNull(_newConfiguration.CurrentConfiguration);
            Assert.IsNotNull(_newConfiguration.ConfigurationData);
            Assert.AreEqual <int>(1, _newConfiguration.CurrentConfiguration.OnLoadedCount);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnSavingCount);
            Assert.AreEqual <int>(2, _Logger.TraceLogList.Count);
            //Assert.Fail(); //To get created file the test must fail.
        }