public void GetWithInheritance_Simple() { var collection = new ClassContextCollection(_ccObjectWithMixin, _ccString, _ccListOfT, _ccListOfString); Assert.That(collection.GetWithInheritance(typeof(object)), Is.SameAs(_ccObjectWithMixin)); Assert.That(collection.GetWithInheritance(typeof(string)), Is.SameAs(_ccString)); Assert.That(collection.GetWithInheritance(typeof(List <>)), Is.SameAs(_ccListOfT)); Assert.That(collection.GetWithInheritance(typeof(List <string>)), Is.SameAs(_ccListOfString)); }
public void GetWithInheritance_Inheritance_FromBaseType() { ClassContext inherited1 = _collectionWithObjectAndString.GetWithInheritance(typeof(ClassContextCollectionTest)); Assert.That(inherited1, Is.Not.Null); Assert.That(inherited1.Type, Is.EqualTo(typeof(ClassContextCollectionTest))); Assert.That(inherited1.Mixins.ContainsKey(typeof(NullMixin2)), Is.True); ClassContext inherited2 = _collectionWithObjectAndString.GetWithInheritance(typeof(ClassContextCollectionTest)); Assert.That(inherited2, Is.EqualTo(inherited1)); ClassContext inherited3 = _collectionWithObjectAndString.GetWithInheritance(typeof(int)); Assert.That(inherited3, Is.Not.Null); Assert.That(inherited3.Type, Is.EqualTo(typeof(int))); Assert.That(inherited3.Mixins.ContainsKey(typeof(NullMixin2)), Is.True); }
public void GetWithInheritance_Inheritance_FromInterface() { var classContext = ClassContextObjectMother.Create(typeof(IMixedInterface), typeof(NullMixin), typeof(NullMixin2)); var collection = new ClassContextCollection(classContext); ClassContext inherited = collection.GetWithInheritance(typeof(ClassWithMixedInterface)); Assert.That(inherited, Is.Not.Null); Assert.That(inherited.Type, Is.EqualTo(typeof(ClassWithMixedInterface))); Assert.That(inherited.Mixins.ContainsKey(typeof(NullMixin)), Is.True); Assert.That(inherited.Mixins.ContainsKey(typeof(NullMixin2)), Is.True); }
public void GetWithInheritance_Inheritance_FromGenericTypeDefinition() { var classContext1 = ClassContextObjectMother.Create(typeof(List <>), typeof(NullMixin3)); var classContext2 = ClassContextObjectMother.Create(typeof(List <string>), typeof(NullMixin4)); var collection = new ClassContextCollection(classContext1, classContext2); ClassContext inherited4 = collection.GetWithInheritance(typeof(List <int>)); Assert.That(inherited4, Is.Not.Null); Assert.That(inherited4.Type, Is.EqualTo(typeof(List <int>))); Assert.That(inherited4.Mixins.ContainsKey(typeof(NullMixin3)), Is.True); Assert.That(inherited4.Mixins.ContainsKey(typeof(NullMixin4)), Is.False); }
public void GetWithInheritance_Null() { Assert.That(_emptyCollection.GetWithInheritance(typeof(int)), Is.Null); }