public void IndexOfTests() { var testContext = _propertyTestData.GetContext(); var a = testContext.GetChildElement("a"); var b = testContext.GetChildElement("b"); var c = testContext.GetChildElement("c"); var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); Assert.True(x.IndexOf(a) < 0); Assert.True(x.IndexOf(b) < 0); Assert.True(x.IndexOf(c) < 0); x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b); Assert.Equal(0, x.IndexOf(a)); Assert.Equal(1, x.IndexOf(b)); Assert.True(x.IndexOf(c) < 0); x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings(), a, b, c); Assert.Equal(0, x.IndexOf(a)); Assert.Equal(1, x.IndexOf(b)); Assert.Equal(2, x.IndexOf(c)); Assert.True(x.IndexOf(null) < 0); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.IndexOf(a)); }
public void DisposeTests() { var testContext = _propertyTestData.GetContext(); var x = new ReadOnlyConfigurationCollection <IChildElement>(null, testContext.ReadOnlyChildConfigurationCollectionPropertyDef, testContext.Configuration.ConfigurationRoot, new ConfigurationObjectSettings()); x.Dispose(); Assert.Throws <ObjectDisposedException>(() => x.IndexOf(null)); }