public void CanUploadImage_should_throw_exception_if_name_not_valid() { var command = new UploadAppImage(); ValidationAssert.Throws(() => GuardApp.CanUploadImage(command), new ValidationError("File is required.", "File")); }
public void CanUploadImage_should_not_throw_exception_if_app_name_is_valid() { var command = new UploadAppImage { File = new AssetFile("file.png", "image/png", 100, () => new MemoryStream()) }; GuardApp.CanUploadImage(command); }
public void CanUploadImage_should_not_throw_exception_if_app_name_is_valid() { var command = new UploadAppImage { File = new NoopAssetFile() }; GuardApp.CanUploadImage(command); }
public static void CanUploadImage(UploadAppImage command) { Guard.NotNull(command, nameof(command)); Validate.It(e => { if (command.File == null) { e(Not.Defined(nameof(command.File)), nameof(command.File)); } }); }
public static void CanUploadImage(UploadAppImage command) { Guard.NotNull(command); Validate.It(() => "Cannot upload image.", e => { if (command.File == null) { e(Not.Defined("File"), nameof(command.File)); } }); }
private async Task UploadAsync(UploadAppImage uploadImage) { var file = uploadImage.File; var image = await assetThumbnailGenerator.GetImageInfoAsync(file.OpenRead()); if (image == null) { throw new ValidationException("File is not an image."); } await assetStore.UploadAsync(uploadImage.AppId.ToString(), file.OpenRead(), true); }
private async Task UploadAsync(UploadAppImage uploadImage) { var file = uploadImage.File; using (var uploadStream = file.OpenRead()) { var image = await assetThumbnailGenerator.GetImageInfoAsync(uploadStream); if (image == null) { throw new ValidationException(T.Get("apps.notImage")); } } using (var uploadStream = file.OpenRead()) { await appImageStore.UploadAsync(uploadImage.AppId.Id, uploadStream); } }
public async Task UploadImage_should_create_events_and_update_state() { var command = new UploadAppImage { File = new AssetFile("image.png", "image/png", 100, () => new MemoryStream()) }; await ExecuteCreateAsync(); var result = await sut.ExecuteAsync(CreateCommand(command)); result.ShouldBeEquivalent(sut.Snapshot); Assert.Equal("image/png", sut.Snapshot.Image !.MimeType); LastEvents .ShouldHaveSameEvents( CreateEvent(new AppImageUploaded { Image = sut.Snapshot.Image }) ); }
public async Task UploadImage_should_create_events_and_update_image() { var command = new UploadAppImage { File = new NoopAssetFile() }; await ExecuteCreateAsync(); var result = await PublishAsync(command); result.ShouldBeEquivalent(sut.Snapshot); Assert.Equal("image/png", sut.Snapshot.Image !.MimeType); LastEvents .ShouldHaveSameEvents( CreateEvent(new AppImageUploaded { Image = sut.Snapshot.Image }) ); }
private void UploadImage(UploadAppImage command) { Raise(command, new AppImageUploaded { Image = new AppImage(command.File.MimeType) }); }
public void UploadImage(UploadAppImage command) { RaiseEvent(SimpleMapper.Map(command, new AppImageUploaded { Image = new AppImage(command.File.MimeType) })); }
public static void CanUploadImage(UploadAppImage command) { Guard.NotNull(command, nameof(command)); }
public void UploadImage(UploadAppImage command) { RaiseEvent(SimpleMapper.Map(command, new AppImageUploaded())); }