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()); }
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); }
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); }
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); }
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()); }
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()); }
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()); }
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()); }
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); }
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); }