public void ReadSaveConfigurationTest() { Logger _Logger = new Logger(); CommonServiceLocator.ServiceLocator.SetLocatorProvider(() => new Container(new object[] { _Logger })); DerivedUANetworkingConfiguration _newConfiguration = new DerivedUANetworkingConfiguration(); FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataConsumer.xml"); Assert.IsNull(_newConfiguration.ConfigurationData); _newConfiguration.ReadConfiguration(_configFile); Assert.IsNotNull(_newConfiguration.ConfigurationData); //SaveConfiguration bool _ConfigurationFileChanged = false; _newConfiguration.OnModified += (x, y) => { _ConfigurationFileChanged = true; }; FileInfo _fi = new FileInfo(@"BleBle.txt"); Assert.IsFalse(_fi.Exists); _newConfiguration.SaveConfiguration(_fi); Assert.IsFalse(_ConfigurationFileChanged); Assert.IsNotNull(_newConfiguration.CurrentConfiguration); _fi.Refresh(); Assert.IsTrue(_fi.Exists); Assert.AreEqual <int>(2, _Logger.TraceLogList.Count); }
public void ReadConfigurationTest() { Logger _Logger = new Logger(); CommonServiceLocator.ServiceLocator.SetLocatorProvider(() => new Container(new object[] { _Logger })); DerivedUANetworkingConfiguration _newConfiguration = new DerivedUANetworkingConfiguration(); FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataConsumer.xml"); Assert.IsTrue(_configFile.Exists); bool _ConfigurationFileChanged = false; Assert.IsNull(_newConfiguration.ConfigurationData); _newConfiguration.OnModified += (x, y) => { _ConfigurationFileChanged = true; }; _newConfiguration.ReadConfiguration(_configFile); Assert.IsTrue(_ConfigurationFileChanged); Assert.IsNotNull(_newConfiguration.CurrentConfiguration); Assert.IsNotNull(_newConfiguration.ConfigurationData); Assert.AreEqual <int>(1, _Logger.TraceLogList.Count); Logger.TraceLogEntity _logEntry = _Logger.TraceLogList[0]; Assert.AreEqual <TraceEventType>(TraceEventType.Verbose, _logEntry.EventType); Assert.AreEqual <int>(52, _logEntry.Id); string _logMessage = $"Data = {_logEntry.Data}, EventType = {_logEntry.EventType} Id = {_logEntry.Id}"; Debug.WriteLine(_logMessage); }
public void ReadConfigurationTest() { DerivedUANetworkingConfiguration _newConfiguration = new DerivedUANetworkingConfiguration(); _newConfiguration.ComposeParts(); FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataConsumer.xml"); Assert.IsTrue(_configFile.Exists); bool _ConfigurationFileChanged = false; Assert.IsNull(_newConfiguration.ConfigurationData); _newConfiguration.OnModified += (x, y) => { _ConfigurationFileChanged = true; }; _newConfiguration.ReadConfiguration(_configFile); Assert.IsTrue(_ConfigurationFileChanged); Assert.IsNotNull(_newConfiguration.CurrentConfiguration); Assert.IsNotNull(_newConfiguration.ConfigurationData); }
public void OnChangedConfigurationTest() { Logger _Logger = new Logger(); CommonServiceLocator.ServiceLocator.SetLocatorProvider(() => new Container(new object[] { _Logger })); DerivedUANetworkingConfiguration _newConfiguration = new DerivedUANetworkingConfiguration(); FileInfo _configFile = new FileInfo(@"TestData\ConfigurationDataConsumer.xml"); Assert.IsTrue(_configFile.Exists); bool _ConfigurationFileChanged = false; Assert.IsNull(_newConfiguration.ConfigurationData); _newConfiguration.ReadConfiguration(_configFile); Assert.IsNotNull(_newConfiguration.ConfigurationData); _newConfiguration.OnModified += (x, y) => { _ConfigurationFileChanged = true; }; Assert.IsNotNull(_newConfiguration.ConfigurationData.OnChanged); _newConfiguration.ConfigurationData.OnChanged(); Assert.IsTrue(_ConfigurationFileChanged); Assert.AreEqual <int>(1, _Logger.TraceLogList.Count); }