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);
        }
Beispiel #2
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.
        }