public void AddTypeWithParentTypeFirst() { var repository = new PluginRepository(); Func <Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); var objectDefinition = TypeDefinition.CreateDefinition(typeof(object), identityGenerator); repository.AddType(objectDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(object).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(object)))); var stringDefinition = TypeDefinition.CreateDefinition(typeof(string), identityGenerator); repository.AddType(stringDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(string).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(string)))); Assert.IsTrue(repository.IsSubTypeOf(TypeIdentity.CreateDefinition(typeof(object)), TypeIdentity.CreateDefinition(typeof(string)))); }
public void AddTypeWithStandaloneGenericInterfaceType() { var repository = new PluginRepository(); Func <Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); var definition = TypeDefinition.CreateDefinition(typeof(IComparer <>), identityGenerator); repository.AddType(definition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(IComparer <>).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(IComparer <>)))); Assert.AreSame(definition, repository.TypeByName(typeof(IComparer <>).AssemblyQualifiedName)); Assert.AreSame(definition, repository.TypeByIdentity(TypeIdentity.CreateDefinition(typeof(IComparer <>)))); }
public void AddTypeWithGenericParentLast() { var repository = new PluginRepository(); Func <Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); var listDefinition = TypeDefinition.CreateDefinition(typeof(List <>), identityGenerator); repository.AddType(listDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(List <>).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(List <>)))); var enumerableDefinition = TypeDefinition.CreateDefinition(typeof(IEnumerable <>), identityGenerator); repository.AddType(enumerableDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(IEnumerable <>).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(IEnumerable <>)))); Assert.IsTrue( repository.IsSubTypeOf( TypeIdentity.CreateDefinition(typeof(IEnumerable <>)), TypeIdentity.CreateDefinition(typeof(List <>)))); }
public void AddTypeWithGenericParentFirst() { var repository = new PluginRepository(); Func<Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); var enumerableDefinition = TypeDefinition.CreateDefinition(typeof(IEnumerable<>), identityGenerator); repository.AddType(enumerableDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(IEnumerable<>).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(IEnumerable<>)))); var listDefinition = TypeDefinition.CreateDefinition(typeof(List<>), identityGenerator); repository.AddType(listDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(List<>).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(List<>)))); Assert.IsTrue( repository.IsSubTypeOf( TypeIdentity.CreateDefinition(typeof(IEnumerable<>)), TypeIdentity.CreateDefinition(typeof(List<>)))); }
public void AddTypeWithStandaloneInterfaceType() { var repository = new PluginRepository(); Func<Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); var definition = TypeDefinition.CreateDefinition(typeof(IEnumerable), identityGenerator); repository.AddType(definition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(IEnumerable).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(IEnumerable)))); Assert.AreSame(definition, repository.TypeByName(typeof(IEnumerable).AssemblyQualifiedName)); Assert.AreSame(definition, repository.TypeByIdentity(TypeIdentity.CreateDefinition(typeof(IEnumerable)))); }
public void AddTypeWithParentTypeLast() { var repository = new PluginRepository(); Func<Type, TypeIdentity> identityGenerator = t => TypeIdentity.CreateDefinition(t); var stringDefinition = TypeDefinition.CreateDefinition(typeof(string), identityGenerator); repository.AddType(stringDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(string).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(string)))); var objectDefinition = TypeDefinition.CreateDefinition(typeof(object), identityGenerator); repository.AddType(objectDefinition); Assert.IsTrue(repository.ContainsDefinitionForType(typeof(object).AssemblyQualifiedName)); Assert.IsTrue(repository.ContainsDefinitionForType(TypeIdentity.CreateDefinition(typeof(object)))); Assert.IsTrue(repository.IsSubTypeOf(TypeIdentity.CreateDefinition(typeof(object)), TypeIdentity.CreateDefinition(typeof(string)))); }