public async Task Should_toggle_application_feature() { var application = new Application("App01", "0.1"); var feature = new Feature("isButtonGreen", false); await AddEntity(application, feature); var newFeature = await ExecuteCommand((context) => { FeatureAppService featureAppService = GetFeatureAppService(context); return(featureAppService.AddApplicationFeature(new ApplicationFeatureModel("App01", "0.1", "isButtonGreen", true))); }); await ExecuteCommand((context) => { FeatureAppService featureAppService = GetFeatureAppService(context); return(featureAppService.ToggleApplicationFeature(new ApplicationFeatureModel("App01", "0.1", "isButtonGreen", false))); }); var persistedEntity = await ExecuteCommand((contexto) => { var featureRepository = new ApplicationFeatureRepository(contexto); return(featureRepository.GetAsync(newFeature.Id)); }); using (new AssertionScope()) { persistedEntity.ApplicationId.Should().Be(application.Id); persistedEntity.FeatureId.Should().Be(feature.Id); persistedEntity.IsActive.Should().BeFalse(); } }
public async Task Should_check_application_feature() { var application = new Application("App01", "0.1"); var feature = new Feature("isButtonGreen", false); await AddEntity(application, feature); var newFeature = await ExecuteCommand((context) => { FeatureAppService featureAppService = GetFeatureAppService(context); return(featureAppService.AddApplicationFeature(new ApplicationFeatureModel("App01", "0.1", "isButtonGreen", true))); }); var featureCheck = await ExecuteCommand((context) => { FeatureAppService featureAppService = GetFeatureAppService(context); return(featureAppService.Check("App01", "0.1", "isButtonGreen")); }); using (new AssertionScope()) { featureCheck.Enabled.Should().BeTrue(); featureCheck.Mesage.Should().Be(DomainMessage.FeatureEnabled); } }
public async Task Should_return_null_and_raise_error_when_adding_new_application_feature_with_invalid_data() { var feature = new Feature("isButtonGreen", false); await AddEntity(feature); var newFeature = await ExecuteCommand((context) => { FeatureAppService featureAppService = GetFeatureAppService(context); return(featureAppService.AddApplicationFeature(new ApplicationFeatureModel("App01", "0.1", "isButtonGreen", true))); }); using (new AssertionScope()) { newFeature.Should().BeNull(); await _mediator.Received(1).Publish(Arg.Is <ErrorNotification>(d => d.Error.Equals(DomainMessageError.ApplicationCannotBeNull))); } }