public async void Go_Should_Return_Correctly() { var response = new HexbotifiedImage(); _transformer.Transform(Arg.Any <Image <Rgb24> >(), Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>(), Arg.Any <string>(), Arg.Any <bool>()).Returns(response); var actual = await _hexbotifier.Go(null, null, null, null, null, null); actual.Should().Be(response); }
public async void Get_Should_Return_Correctly() { var service = Substitute.For <IHexbotifier>(); var response = new HexbotifiedImage { ContentType = "image/jpeg", Image = new byte[] { 123, 234, 0 } }; service.Go(Arg.Any <int?>(), Arg.Any <int?>(), Arg.Any <int?>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <bool?>()).Returns(response); var actual = await _controller.Get(service); actual.Should().BeOfType <FileContentResult>(); actual.As <FileContentResult>().ContentType.Should().Be(response.ContentType); actual.As <FileContentResult>().FileContents.Should().BeEquivalentTo(response.Image); }
private HexbotifiedImage GetHexbotifiedImage(Image <Rgb24> image) { var response = new HexbotifiedImage(); using (var stream = new MemoryStream()) { if (image.Frames.Count > 1) { image.SaveAsGif(stream); response.ContentType = "image/gif"; } else { image.SaveAsPng(stream); response.ContentType = "image/png"; } response.Image = stream.ToArray(); } return(response); }