public void ShouldNotAllowToExecuteWhenNotProvidedWayToSetImage() { // Given var command = new SetOutputImageCommand(_imageConverter) { OnImageUpdate = null }; // When // Then Assert.IsFalse(command.CanExecute(null)); Assert.Throws <CannotExecuteCommandException>(() => command.Execute(null)); }
public void ShouldSetOutputImageToNothingWhenInputImageWasNothing() { // Given BitmapSource outputImage = new BitmapImage(); var command = new SetOutputImageCommand(_imageConverter) { OnImageUpdate = value => outputImage = value }; // When command.Execute(null); // Then Assert.IsNull(outputImage); }
public void ShouldSetOutputImageWhenInputImageWas8BppImage() { // Given BitmapSource outputImage = null; var imageModel = new ImageModel(2, 2, ImageBitDepth.Bpp8); var inputImage = new Image(new byte[] { 1, 2, 3, 4 }, imageModel); var command = new SetOutputImageCommand(_imageConverter) { OnImageUpdate = value => outputImage = value }; // When command.Execute(inputImage); // Then Assert.IsTrue(BitmapImageIsSameAsImage(outputImage, inputImage)); }
public void ShouldSetOutputImageWhenInputImageWas12BppImage() { // Given BitmapSource outputImage = null; var imageModel = new ImageModel(2, 2, ImageBitDepth.Bpp12); var inputImage = new Image(new ushort[] { 0, 1024, 2048, 4095 }, imageModel); var expectedImage = new Image(new ushort[] { 0, 64, 128, 255 }, imageModel); var command = new SetOutputImageCommand(_imageConverter) { OnImageUpdate = value => outputImage = value }; // When command.Execute(inputImage); // Then Assert.IsTrue(BitmapImageIsSameAsImage(outputImage, expectedImage)); }