public static TestServiceCollection Build(Action <IServiceCollection> services) { var test = new TestServiceCollection { Services = new ServiceCollection() }; services(test.Services); test.ServiceProvider = test.Services.BuildServiceProvider(); return(test); }
public void Can_replace_app_sender_to_test_sender() { // arrange var sp = TestServiceCollection.Build(services => { // as in the app services.AddMailing() .AddSmtpSender(); // as in the test services.AddSenderMemory(); }); // assert sp.ServiceProvider.GetService <FluentEmail.Core.Interfaces.ISender>().ShouldBeOfType <MemorySender>(); }