public void CanRename_should_throw_exception_if_name_not_defined() { var command = new RenameAsset(); ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"), new ValidationError("Name is required.", "FileName")); }
public void CanRename_not_should_throw_exception_if_name_are_different() { var command = new RenameAsset { FileName = "new-name" }; GuardAsset.CanRename(command, "asset-name"); }
public void CanRename_should_throw_exception_if_name_are_the_same() { var command = new RenameAsset { FileName = "asset-name" }; Assert.Throws <ValidationException>(() => GuardAsset.CanRename(command, "asset-name")); }
public AssetDomainObject Rename(RenameAsset command) { VerifyCreatedAndNotDeleted(); RaiseEvent(SimpleMapper.Map(command, new AssetRenamed())); return(this); }
protected Task On(RenameAsset command, CommandContext context) { return(handler.UpdateSyncedAsync <AssetDomainObject>(context, a => { GuardAsset.CanRename(command, a.Snapshot.FileName); a.Rename(command); })); }
public void CanRename_should_throw_exception_if_name_are_the_same() { var command = new RenameAsset { FileName = "asset-name" }; ValidationAssert.Throws(() => GuardAsset.CanRename(command, "asset-name"), new ValidationError("Asset has already this name.", "FileName")); }
public AssetDomainObject Rename(RenameAsset command) { Guard.Valid(command, nameof(command), () => "Cannot rename asset."); VerifyCreatedAndNotDeleted(); VerifyDifferentNames(command.FileName, () => "Cannot rename asset."); RaiseEvent(SimpleMapper.Map(command, new AssetRenamed())); return(this); }
public static void CanRename(RenameAsset command, string oldName) { Guard.NotNull(command, nameof(command)); Validate.It(() => "Cannot rename asset.", error => { if (string.IsNullOrWhiteSpace(command.FileName)) { error(new ValidationError("Name must be defined.", nameof(command.FileName))); } if (string.Equals(command.FileName, oldName)) { error(new ValidationError("Name is equal to old name.", nameof(command.FileName))); } }); }
public static void CanRename(RenameAsset command, string oldName) { Guard.NotNull(command, nameof(command)); Validate.It(() => "Cannot rename asset.", e => { if (string.IsNullOrWhiteSpace(command.FileName)) { e("Name is required.", nameof(command.FileName)); } if (string.Equals(command.FileName, oldName)) { e("Asset has already this name.", nameof(command.FileName)); } }); }
public static void CanRename(RenameAsset command, string oldName) { Guard.NotNull(command, nameof(command)); Validate.It(() => "Cannot rename asset.", e => { if (string.IsNullOrWhiteSpace(command.FileName)) { e(Not.Defined("Name"), nameof(command.FileName)); } if (string.Equals(command.FileName, oldName)) { e(Not.New("Asset", "name"), nameof(command.FileName)); } }); }
public async Task Rename_should_create_events() { var command = new RenameAsset { FileName = "my-new-image.png" }; await ExecuteCreateAsync(); var result = await sut.ExecuteAsync(CreateAssetCommand(command)); result.ShouldBeEquivalent(new EntitySavedResult(1)); Assert.Equal("my-new-image.png", sut.Snapshot.FileName); LastEvents .ShouldHaveSameEvents( CreateAssetEvent(new AssetRenamed { FileName = "my-new-image.png" }) ); }
public void Rename(RenameAsset command) { RaiseEvent(SimpleMapper.Map(command, new AssetRenamed())); }
protected Task On(RenameAsset command, CommandContext context) { return(handler.UpdateAsync <AssetDomainObject>(context, c => c.Rename(command))); }
public void Rename(RenameAsset command) { VerifyNotDeleted(); RaiseEvent(SimpleMapper.Map(command, new AssetRenamed())); }
static void Init() { win = ScriptableObject.CreateInstance(typeof(RenameAsset)) as RenameAsset; win.OnSelectionChange(); win.ShowUtility(); }
public void CanRename_should_throw_exception_if_name_not_defined() { var command = new RenameAsset(); Assert.Throws <ValidationException>(() => GuardAsset.CanRename(command, "asset-name")); }