public void AddRemoveTest() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("MyName", typeof(Object).AssemblyQualifiedName); xmlIncludeTypes.Add(xmlIncludeType); Assert.AreEqual(1, xmlIncludeTypes.Count); xmlIncludeTypes.Remove(xmlIncludeType.Name); }
public void CanAddTwoConfigSectionsToCollection() { XmlIncludeTypeData sectionOne = new XmlIncludeTypeData("SectionOne", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeData sectionTwo = new XmlIncludeTypeData("SectionTwo", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(sectionOne); collection.Add(sectionTwo); Assert.AreEqual(2, collection.Count); }
public void CanAddTwoConfigSectionsToCollection() { XmlIncludeTypeData sectionOne = new XmlIncludeTypeData("SectionOne", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeData sectionTwo = new XmlIncludeTypeData("SectionTwo", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(sectionOne); collection.Add(sectionTwo); Assert.AreEqual(2, collection.Count); }
public void CanAddConfigSectionToCollection() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("Bill", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(xmlIncludeType); Assert.AreEqual(1, collection.Count); }
public void CanAddConfigSectionToCollection() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("Bill", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(xmlIncludeType); Assert.AreEqual(1, collection.Count); }
public void CanGetFirstElementFromCollection() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("Bill", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(xmlIncludeType); IEnumerator enumerator = collection.GetEnumerator(); enumerator.MoveNext(); Assert.AreEqual("Bill", ((XmlIncludeTypeData)enumerator.Current).Name); }
public void IndexerTest() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("Bill", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(xmlIncludeType); XmlIncludeTypeData billSection = collection["Bill"]; Assert.AreSame(xmlIncludeType, billSection); }
public void CanGetFirstElementFromCollection() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("Bill", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(xmlIncludeType); IEnumerator enumerator = collection.GetEnumerator(); enumerator.MoveNext(); Assert.AreEqual("Bill", ((XmlIncludeTypeData)enumerator.Current).Name); }
public void CannotInvokeNonPublicMethodWhenCallsMadeDirectly() { ReflectionPermission permission = new ReflectionPermission(ReflectionPermissionFlag.TypeInformation); permission.Deny(); XmlIncludeTypeDataCollection xmlIncludeTypes = new XmlIncludeTypeDataCollection(); xmlIncludeTypes.Add(new XmlIncludeTypeData("shouldNotBeAccessible", typeof(TestingInternal.ShouldNotBeAccessible).AssemblyQualifiedName)); RuntimeConfigurationView view = new RuntimeConfigurationView(new ConfigurationContext(new ConfigurationDictionary())); Type [] collectedTypes = view.CollectTypes(xmlIncludeTypes); Assert.AreEqual(1, collectedTypes.Length); }
public void CannotInvokeNonPublicMethodWhenCallsMadeThroughReflection() { ReflectionPermission permission = new ReflectionPermission(ReflectionPermissionFlag.TypeInformation); permission.Deny(); XmlIncludeTypeDataCollection xmlIncludeTypes = new XmlIncludeTypeDataCollection(); xmlIncludeTypes.Add(new XmlIncludeTypeData("shouldNotBeAccessible", typeof(TestingInternal.ShouldNotBeAccessible).AssemblyQualifiedName)); RuntimeConfigurationView view = new RuntimeConfigurationView(new ConfigurationContext(new ConfigurationDictionary())); MethodInfo collectTypes = view.GetType().GetMethod("CollectTypes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(XmlIncludeTypeDataCollection)}, null); object returnedTypes = collectTypes.Invoke(view, new object[] { xmlIncludeTypes }); Type [] collectedTypes = returnedTypes as Type[]; Assert.AreEqual(1, collectedTypes.Length); }
public void CannotInvokeNonPublicMethodWhenCallsMadeDirectly() { ReflectionPermission permission = new ReflectionPermission(ReflectionPermissionFlag.TypeInformation); permission.Deny(); XmlIncludeTypeDataCollection xmlIncludeTypes = new XmlIncludeTypeDataCollection(); xmlIncludeTypes.Add(new XmlIncludeTypeData("shouldNotBeAccessible", typeof(TestingInternal.ShouldNotBeAccessible).AssemblyQualifiedName)); RuntimeConfigurationView view = new RuntimeConfigurationView(new ConfigurationContext(new ConfigurationDictionary())); Type [] collectedTypes = view.CollectTypes(xmlIncludeTypes); Assert.AreEqual(1, collectedTypes.Length); }
public void CannotInvokeNonPublicMethodWhenCallsMadeThroughReflection() { ReflectionPermission permission = new ReflectionPermission(ReflectionPermissionFlag.TypeInformation); permission.Deny(); XmlIncludeTypeDataCollection xmlIncludeTypes = new XmlIncludeTypeDataCollection(); xmlIncludeTypes.Add(new XmlIncludeTypeData("shouldNotBeAccessible", typeof(TestingInternal.ShouldNotBeAccessible).AssemblyQualifiedName)); RuntimeConfigurationView view = new RuntimeConfigurationView(new ConfigurationContext(new ConfigurationDictionary())); MethodInfo collectTypes = view.GetType().GetMethod("CollectTypes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(XmlIncludeTypeDataCollection) }, null); object returnedTypes = collectTypes.Invoke(view, new object[] { xmlIncludeTypes }); Type [] collectedTypes = returnedTypes as Type[]; Assert.AreEqual(1, collectedTypes.Length); }
public void IndexerTest() { XmlIncludeTypeData xmlIncludeType = new XmlIncludeTypeData("Bill", typeof(Object).AssemblyQualifiedName); XmlIncludeTypeDataCollection collection = new XmlIncludeTypeDataCollection(); collection.Add(xmlIncludeType); XmlIncludeTypeData billSection = collection["Bill"]; Assert.AreSame(xmlIncludeType, billSection); }