public void CanRemoveLanguage_should_throw_exception_if_language_is_null() { var command = new RemoveLanguage(); ValidationAssert.Throws(() => GuardAppLanguages.CanRemove(languages_0, command), new ValidationError("Language code is required.", "Language")); }
public static void CanRemove(RemoveLanguage command, IAppEntity app) { Guard.NotNull(command, nameof(command)); var languages = app.Languages; Validate.It(e => { var language = command.Language; if (language == null) { e(Not.Defined(nameof(command.Language)), nameof(command.Language)); } else { EnsureConfigExists(languages, language); if (languages.IsMaster(language)) { e(T.Get("apps.languages.masterLanguageNotRemovable")); } } }); }
public void CanRemoveLanguage_should_throw_exception_if_language_is_master() { var command = new RemoveLanguage { Language = Language.DE }; Assert.Throws <ValidationException>(() => GuardAppLanguages.CanRemove(languages_0, command)); }
public void CanRemoveLanguage_should_not_throw_exception_if_language_is_valid() { var command = new RemoveLanguage { Language = Language.DE }; GuardAppLanguages.CanRemove(languages, command); }
public void CanRemoveLanguage_should_throw_exception_if_language_not_found() { var command = new RemoveLanguage { Language = Language.EN }; Assert.Throws <DomainObjectNotFoundException>(() => GuardAppLanguages.CanRemove(languages_0, command)); }
public AppDomainObject RemoveLanguage(RemoveLanguage command) { ThrowIfNotCreated(); RaiseEvent(SimpleMapper.Map(command, new AppLanguageRemoved())); return(this); }
protected Task On(RemoveLanguage command, CommandContext context) { return(handler.UpdateSyncedAsync <AppDomainObject>(context, a => { GuardAppLanguages.CanRemove(a.Snapshot.LanguagesConfig, command); a.RemoveLanguage(command); })); }
public void CanRemoveLanguage_should_throw_exception_if_language_is_master() { var command = new RemoveLanguage { Language = Language.DE }; ValidationAssert.Throws(() => GuardAppLanguages.CanRemove(languages_0, command), new ValidationError("Master language cannot be removed.")); }
public async Task <IActionResult> DeleteLanguage(string app, string language) { var command = new RemoveLanguage { Language = ParseLanguage(language) }; var response = await InvokeCommandAsync(command); return(Ok(response)); }
public void CanRemoveLanguage_should_not_throw_exception_if_language_is_valid() { var command = new RemoveLanguage { Language = Language.EN }; var languages_1 = languages_0.Set(new LanguageConfig(Language.EN)); GuardAppLanguages.CanRemove(languages_1, command); }
public AppDomainObject RemoveLanguage(RemoveLanguage command) { Guard.Valid(command, nameof(command), () => "Cannot remove language"); ThrowIfNotCreated(); RaiseEvent(SimpleMapper.Map(command, new AppLanguageRemoved())); return(this); }
public static void CanRemove(LanguagesConfig languages, RemoveLanguage command) { Guard.NotNull(command, nameof(command)); var config = GetConfigOrThrow(languages, command.Language); Validate.It(() => "Cannot remove language.", e => { if (command.Language == null) { e("Language code is required.", nameof(command.Language)); } if (languages.Master == config) { e("Master language cannot be removed."); } }); }
public static void CanRemove(LanguagesConfig languages, RemoveLanguage command) { Guard.NotNull(command, nameof(command)); var languageConfig = GetLanguageConfigOrThrow(languages, command.Language); Validate.It(() => "Cannot remove language.", error => { if (command.Language == null) { error(new ValidationError("Language cannot be null.", nameof(command.Language))); } if (languages.Master == languageConfig) { error(new ValidationError("Language config is master.", nameof(command.Language))); } }); }
public async Task RemoveLanguage_should_create_events_and_update_state() { var command = new RemoveLanguage { Language = Language.DE }; await ExecuteCreateAsync(); await ExecuteAddLanguageAsync(Language.DE); var result = await sut.ExecuteAsync(CreateCommand(command)); result.ShouldBeEquivalent(sut.Snapshot); Assert.False(sut.Snapshot.LanguagesConfig.Contains(Language.DE)); LastEvents .ShouldHaveSameEvents( CreateEvent(new AppLanguageRemoved { Language = Language.DE }) ); }
public static void CanRemove(LanguagesConfig languages, RemoveLanguage command) { Guard.NotNull(command); Validate.It(() => "Cannot remove language.", e => { var language = command.Language; if (language == null) { e(Not.Defined("Language code"), nameof(command.Language)); } else { EnsureConfigExists(languages, language); if (languages.IsMaster(language)) { e("Master language cannot be removed."); } } }); }
protected Task On(RemoveLanguage command, CommandContext context) { return(handler.UpdateAsync <AppDomainObject>(context, a => a.RemoveLanguage(command))); }
public void RemoveLanguage(RemoveLanguage command) { RaiseEvent(SimpleMapper.Map(command, new AppLanguageRemoved())); }
private void RemoveLanguage(RemoveLanguage command) { Raise(command, new AppLanguageRemoved()); }
public void CanRemoveLanguage_should_throw_exception_if_language_is_null() { var command = new RemoveLanguage(); Assert.Throws <ValidationException>(() => GuardAppLanguages.CanRemove(languages, command)); }