Пример #1
0
        public void Register_ClrType_InferSchemaTypes()
        {
            // arrange
            var initialTypes = new List <ITypeReference>();

            initialTypes.Add(new ClrTypeReference(
                                 typeof(Foo),
                                 TypeContext.Output));

            var serviceProvider = new EmptyServiceProvider();

            var typeRegistrar = new TypeRegistrar(
                serviceProvider, initialTypes);

            // act
            typeRegistrar.Complete();

            // assert
            typeRegistrar.Registerd
            .Select(t => t.Value.Type)
            .OfType <IHasClrType>()
            .ToDictionary(
                t => t.GetType().GetTypeName(),
                t => t.ClrType.GetTypeName())
            .MatchSnapshot(new SnapshotNameExtension("registered"));

            typeRegistrar.ClrTypes.ToDictionary(
                t => t.Key.ToString(),
                t => t.Value.ToString())
            .MatchSnapshot(new SnapshotNameExtension("clr"));
        }
Пример #2
0
        public void Register_SchemaType_ClrTypeExists()
        {
            // arrange
            var initialTypes = new List <ITypeReference>();

            initialTypes.Add(new ClrTypeReference(
                                 typeof(FooType),
                                 TypeContext.Output));

            var serviceProvider = new EmptyServiceProvider();

            var typeRegistrar = new TypeRegistrar(
                serviceProvider,
                DescriptorContext.Create(),
                initialTypes,
                new Dictionary <ITypeReference, ITypeReference>(),
                new Dictionary <string, object>(),
                new AggregateTypeInitilizationInterceptor());

            // act
            typeRegistrar.Complete();

            // assert
            typeRegistrar.Registerd
            .Select(t => t.Value.Type)
            .OfType <IHasClrType>()
            .ToDictionary(
                t => t.GetType().GetTypeName(),
                t => t.ClrType.GetTypeName())
            .MatchSnapshot(new SnapshotNameExtension("registered"));

            typeRegistrar.ClrTypes.ToDictionary(
                t => t.Key.ToString(),
                t => t.Value.ToString())
            .MatchSnapshot(new SnapshotNameExtension("clr"));
        }