Example #1
0
            internal static UANetworkingConfigurationCustomConfigurationDataFixture GetUANetworkingConfigurationFixture()
            {
                UANetworkingConfigurationCustomConfigurationDataFixture _item = new UANetworkingConfigurationCustomConfigurationDataFixture();

                _item.CurrentConfiguration = CustomConfigurationData.LoadConsumer();
                return(_item);
            }
Example #2
0
        public void CustomConfigurationDataTest()
        {
            Logger _Logger = new Logger();

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

            Assert.IsNotNull(_newConfiguration.CurrentConfiguration);
            Assert.AreEqual <int>(0, _newConfiguration.CurrentConfiguration.OnLoadedCount);
            FileInfo _configFile = new FileInfo(@"TestData\CustomConfigurationData.new.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.
        }