public void Given_rule_is_configured_via_factory_and_serviceCollection_it_should_add_instance_to_rule_collection() { var configuredRule = new TestValidationRule(); IServiceProvider providedServiceProvider = null; IIbanNetOptionsBuilder returnedBuilder = _builder .WithRule(s => { providedServiceProvider = s; return(configuredRule); }); // Act IServiceProvider services = _serviceCollection.BuildServiceProvider(); // Assert IbanValidatorOptions opts = services.GetService <IOptions <IbanValidatorOptions> >().Value; opts.Should() .HaveRule <IIbanValidationRule>() .And.HaveCount(1) .And.Subject.Single() .Should() .BeSameAs(configuredRule); providedServiceProvider.Should().NotBeNull(); returnedBuilder.Should().BeSameAs(_builder); }
public void Given_rule_is_configured_via_factory_and_serviceCollection_it_should_add_instance_to_rule_collection() { var configuredRule = new TestValidationRule(); IComponentContext providedComponentContext = null; IIbanNetOptionsBuilder returnedBuilder = _builder .WithRule(ctx => { providedComponentContext = ctx; return(configuredRule); }); // Act IContainer container = _containerBuilder.Build(); // Assert IbanValidatorOptions opts = container.Resolve <IbanValidatorOptions>(); opts.Should() .HaveRule <IIbanValidationRule>() .And.HaveCount(1) .And.Subject.Single() .Should() .BeSameAs(configuredRule); providedComponentContext.Should().NotBeNull(); returnedBuilder.Should().BeSameAs(_builder); }
private void VerifyCalled(Action <IbanValidatorOptionsAssertions> should) { Func <Action <DependencyResolverAdapter, IbanValidatorOptions>, bool> assert = configureAction => { var opts = new IbanValidatorOptions(); DependencyResolverAdapter adapter = new Mock <DependencyResolverAdapter>().Object; configureAction(adapter, opts); should(opts.Should()); return(true); }; Subject.Verify(m => m.Configure(It.Is <Action <DependencyResolverAdapter, IbanValidatorOptions> >(action => assert(action)))); }