Ejemplo n.º 1
0
        public void Should_register_multiple_validators_passed_in_by_configurator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithValidators(typeof(TestModelValidator), typeof(DuplicateTestModelOne)));

            //Then
            var validators = serviceCollection.Where(x => x.ServiceType == typeof(IValidator));

            Assert.Equal(2, validators.Count());
        }
Ejemplo n.º 2
0
        public void Should_register_assembly_scanned_valdators_when_no_configurator_used()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection);

            //Then
            var validators = serviceCollection.Where(x => x.ServiceType == typeof(IValidator));

            Assert.True(validators.Count() > 1);
        }
Ejemplo n.º 3
0
        public void Should_register_validators_passed_in_by_configurator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithValidator <TestModelValidator>());

            //Then
            var validators = serviceCollection.Where(x => x.ServiceType == typeof(IValidator));

            Assert.Single(validators);
        }
Ejemplo n.º 4
0
        public void Should_register_modules_passed_in_by_configurator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithModule <TestModule>());

            //Then
            var modules = serviceCollection.Where(x => x.ServiceType == typeof(ICarterModule));

            Assert.Single(modules);
        }
Ejemplo n.º 5
0
        public void Should_register_multiple_modules_passed_in_by_configurator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithModules(typeof(TestModule), typeof(StreamModule)));

            //Then
            var modules = serviceCollection.Where(x => x.ServiceType == typeof(ICarterModule));

            Assert.Equal(2, modules.Count());
        }
Ejemplo n.º 6
0
        public void Should_register_no_response_negotiators_passed_in_by_configurator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithEmptyResponseNegotiators());

            //Then
            var responseNegotiators = serviceCollection.Where(x => x.ServiceType == typeof(IResponseNegotiator));

            Assert.Equal(1, responseNegotiators.Count());
        }
Ejemplo n.º 7
0
        public void Should_register_multiple_responsenegotiators_passed_in_by_configurator_and_default_json_negotiator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithResponseNegotiators(typeof(TestResponseNegotiator), typeof(TestXmlResponseNegotiator)));

            //Then
            var responsenegotiators = serviceCollection.Where(x => x.ServiceType == typeof(IResponseNegotiator));

            Assert.Equal(3, responsenegotiators.Count());
        }
Ejemplo n.º 8
0
        public void Should_register_multiple_statuscodehandlers_passed_in_by_configutator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithStatusCodeHandlers(typeof(TeapotStatusCodeHandler), typeof(NoOpStatusCodeHandler)));

            //Then
            var statuscodehandlers = serviceCollection.Where(x => x.ServiceType == typeof(IStatusCodeHandler));

            Assert.Equal(2, statuscodehandlers.Count());
        }
Ejemplo n.º 9
0
        public void Should_register_statuscodehandlers_passed_in_by_configutator()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection, configurator: configurator => configurator.WithStatusCodeHandler <TeapotStatusCodeHandler>());

            //Then
            var statuscodehandlers = serviceCollection.Where(x => x.ServiceType == typeof(IStatusCodeHandler));

            Assert.Single(statuscodehandlers);
        }
Ejemplo n.º 10
0
        public void Should_register_assembly_scanned_statuscodehandlers_when_no_configurator_used()
        {
            //Given
            var serviceCollection = new ServiceCollection();

            //When
            CarterExtensions.AddCarter(serviceCollection);

            //Then
            var statuscodehandlers = serviceCollection.Where(x => x.ServiceType == typeof(IStatusCodeHandler));

            Assert.True(statuscodehandlers.Count() > 1);
        }