public void Services_FallbackEnvironmentRegisterFallbackService_ResolvesCorrectService() { using (var context = ApplicationContext.Create(application => application .ConfigureForUnitTest() .Environment(environment => environment .Customize(ApplicationEnvironment.Custom("Custom"), custom => custom .Services(services => services .Advanced(advanced => advanced .Register <ISomeService, CustomService>()))) .Fallback(fallback => fallback .Services(services => services .Advanced(advanced => advanced .Register <ISomeService, FallbackService>()))) .OverrideCurrent("Development")))) { var service = context.Resolve <ISomeService>(); Assert.That(service, Is.TypeOf <FallbackService>()); } }
public void CheckExistsCreateIntegrationDb_DisabledForStageAndProduction_VerifyConfiguration() { var stageAndProduction = new[] { ApplicationEnvironment.Stage, ApplicationEnvironment.Production }; void Configure(ApplicationConfiguration application, ApplicationEnvironment current) { application .ConfigureForUnitTest() .Environment(environment => environment .Customize(stageAndProduction, custom => custom .Database(database => database .IntegrationDb(integrationDb => integrationDb .DisableCheckExistsAndCreateDatabaseIfNotFound()))) .OverrideCurrent(current)); } void AssertCheckExistsIfNotFound(ApplicationEnvironment current, bool expectedCheckExists) { using (var context = ApplicationContext.Create(application => Configure(application, current))) { var configuration = context.Resolve <IIntegrationDatabaseConfiguration>(); bool actual = configuration.CheckExistsAndCreateDatabaseIfNotFound; Assert.That(actual, Is.EqualTo(expectedCheckExists), () => $"Expected {expectedCheckExists} but was {actual} for {current}."); } } AssertCheckExistsIfNotFound(ApplicationEnvironment.Development, true); AssertCheckExistsIfNotFound(ApplicationEnvironment.Stage, false); AssertCheckExistsIfNotFound(ApplicationEnvironment.Production, false); AssertCheckExistsIfNotFound(ApplicationEnvironment.Custom("QA"), true); }