public void FindConcreteTypes_InterfaceType_IsExpandedCorrectly() { var collection = new SchemaTypeCollection(); var personType = this.MakeGraphType(typeof(PersonData), TypeKind.OBJECT) as IObjectGraphType; var employeeType = this.MakeGraphType(typeof(EmployeeData), TypeKind.OBJECT) as IObjectGraphType; var personInterfaceType = this.MakeGraphType(typeof(IPersonData), TypeKind.INTERFACE); collection.EnsureGraphType(personInterfaceType); collection.EnsureGraphType(personType, typeof(PersonData)); collection.EnsureGraphType(employeeType, typeof(EmployeeData)); // extract all hte possible concrete types for the interface, should be person and employee var types = collection.FindConcreteTypes(personInterfaceType); Assert.IsNotNull(types); Assert.AreEqual(2, types.Count()); CollectionAssert.Contains(types, typeof(PersonData)); CollectionAssert.Contains(types, typeof(EmployeeData)); }
public void FindConcreteTypes_UnionType_IsExpandedCorrectly() { var server = new TestServerBuilder().Build(); var collection = new SchemaTypeCollection(); var unionTypeMaker = new UnionGraphTypeMaker(server.Schema); var unionType = unionTypeMaker.CreateGraphType(new PersonUnionData(), TypeKind.OBJECT); var personType = this.MakeGraphType(typeof(PersonData), TypeKind.OBJECT) as IObjectGraphType; var employeeType = this.MakeGraphType(typeof(EmployeeData), TypeKind.OBJECT) as IObjectGraphType; collection.EnsureGraphType(personType, typeof(PersonData)); collection.EnsureGraphType(employeeType, typeof(EmployeeData)); collection.EnsureGraphType(unionType); // extract all hte possible concrete types for the interface, should be person and employee var types = collection.FindConcreteTypes(unionType); Assert.IsNotNull(types); Assert.AreEqual(2, types.Count()); CollectionAssert.Contains(types, typeof(PersonData)); CollectionAssert.Contains(types, typeof(EmployeeData)); }