public void Upgrade_Type_From_GenericType() { // arrange var initialTypes = new HashSet <ITypeReference>(); initialTypes.Add(new ClrTypeReference( typeof(ObjectType <Foo>), TypeContext.Output)); initialTypes.Add(new ClrTypeReference( typeof(FooType), TypeContext.Output)); var serviceProvider = new EmptyServiceProvider(); var clrTypeReferences = new Dictionary <IClrTypeReference, ITypeReference>(); var typeDiscoverer = new TypeDiscoverer( initialTypes, clrTypeReferences, DescriptorContext.Create(), new Dictionary <string, object>(), new AggregateTypeInitializationInterceptor(), serviceProvider); // act DiscoveredTypes result = typeDiscoverer.DiscoverTypes(); // assert Assert.Empty(result.Errors); result.Types .Select(t => t.Type) .OfType <IHasClrType>() .ToDictionary( t => t.GetType().GetTypeName(), t => t.ClrType.GetTypeName()) .MatchSnapshot(new SnapshotNameExtension("registered")); clrTypeReferences.ToDictionary( t => t.Key.ToString(), t => t.Value.ToString()) .MatchSnapshot(new SnapshotNameExtension("clr")); }
public void Register_ClrType_InferSchemaTypes() { // arrange var initialTypes = new HashSet <ITypeReference>(); initialTypes.Add(TypeReference.Create( typeof(Foo), TypeContext.Output)); var serviceProvider = new EmptyServiceProvider(); var clrTypeReferences = new Dictionary <ClrTypeReference, ITypeReference>(); var typeDiscoverer = new TypeDiscoverer( initialTypes, clrTypeReferences, DescriptorContext.Create(), new AggregateTypeInitializationInterceptor(), serviceProvider); // act DiscoveredTypes result = typeDiscoverer.DiscoverTypes(); // assert Assert.Empty(result.Errors); new { registered = result.Types .Select(t => t.Type) .OfType <IHasRuntimeType>() .ToDictionary( t => t.GetType().GetTypeName(), t => t.RuntimeType.GetTypeName()), clr = clrTypeReferences.ToDictionary( t => t.Key.ToString(), t => t.Value.ToString()) }.MatchSnapshot(); }
public TypeTrimmer(DiscoveredTypes discoveredTypes) { _discoveredTypes = discoveredTypes; }