Exemplo n.º 1
0
        public void GetConfiguration_InvalidType_ReturnsNull()
        {
            var source = new List <IListDefinitionSource> {
                new ValidProfile()
            };
            var provider = new ListConfigurationProvider(source, factory, optionsMock.Object);

            var result = provider.GetConfiguration(typeof(Result));

            result.Should().BeNull();
        }
Exemplo n.º 2
0
        public void Construct_Valid_Definition_Suceeds()
        {
            var source = new List <IListDefinitionSource> {
                new ValidProfile()
            };
            var provider = new ListConfigurationProvider(source, factory, optionsMock.Object);

            provider.Configurations.Should().HaveCount(1);
            provider.Configurations.First().Value.Should().NotBeNull();
            provider.Configurations.First().Value.ResultType.Name.Should().Be(nameof(Result));
        }
Exemplo n.º 3
0
        public void GetConfiguration_ValidType_Succeeds()
        {
            var source = new List <IListDefinitionSource> {
                new ValidProfile()
            };
            var provider = new ListConfigurationProvider(source, factory, optionsMock.Object);

            var result = provider.GetConfiguration(typeof(Request));

            result.Should().NotBeNull();
            result.ResultType.Name.Should().Be(nameof(Result));
        }
        public void Null_Configuration_Succeeds()
        {
            var configurationProvider    = new ListConfigurationProvider(new List <IListDefinitionSource>(), null, optionsMock.Object);
            var requestActivator         = new Mock <IModelActivator>();
            var requestPropertyActivator = new Mock <IModelPropertyActivator>();

            var services = new ServiceCollection()
                           .AddSingleton <IListConfigurationProvider>(configurationProvider)
                           .AddSingleton(requestActivator.Object)
                           .AddSingleton(requestPropertyActivator.Object)
                           .BuildServiceProvider();

            var context        = new TestModelBinderContext(typeof(Request), services);
            var fallbackBinder = new Mock <IModelBinderProvider>();

            var provider = new GenericSearchModelBinderProvider(fallbackBinder.Object);

            var modelBinder = provider.GetBinder(context);

            modelBinder.Should().BeNull();
        }