public void LoadInstancesUpdatesInstanceWithMatchingType() // TODO: Why? This is inconsistent with the name of the element, Add. { var configuration = new TelemetryConfiguration(); var element = XElement.Parse(@" <List xmlns=""http://schemas.microsoft.com/ApplicationInsights/2013/Settings""> <Add Type=""" + typeof(StubConfigurableWithProperties).AssemblyQualifiedName + @""" > <Int32Property>77</Int32Property> </Add> </List>"); var configurableElement = new StubConfigurableWithProperties(configuration); var instances = new List <object>(); instances.Add(configurableElement); TestableTelemetryConfigurationFactory.LoadInstances(element, instances); var telemetryModules = instances.OfType <StubConfigurableWithProperties>().ToArray(); Assert.Equal(1, telemetryModules.Count()); Assert.Equal(configurableElement, telemetryModules[0]); Assert.Equal(77, configurableElement.Int32Property); }
public void InitializeDoesNotThrowIsModuleInitializationFails() { string configFileContents = Configuration( @"<TelemetryModules> <Add Type = """ + typeof(StubConfigurableWithProperties).AssemblyQualifiedName + @""" /> </TelemetryModules>" ); var module = new StubConfigurableWithProperties(null) { OnInitialize = _ => { throw new ArgumentException(); } }; var modules = new TestableTelemetryModules(); modules.Modules.Add(module); Assert.DoesNotThrow( () => new TestableTelemetryConfigurationFactory().Initialize( new TelemetryConfiguration(), modules, configFileContents)); }