public void Test_TileRenderResponse_Core2() { var response = new TileRenderResponse { TileBitmapData = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, ResultStatus = Types.RequestErrorStatus.OK }; SimpleBinarizableInstanceTester.TestClass(response, "Custom TileRenderResponse_Core2 not same after round trip serialisation"); }
protected void CheckSimpleRenderTileResponse(TileRenderResponse response, DisplayMode?displayMode = null, string fileName = "", string compareToFile = "") { response.Should().NotBeNull(); response.Should().BeOfType <TileRenderResponse>(); if (displayMode != null && (displayMode == DisplayMode.CCA || displayMode == DisplayMode.CCASummary)) { response.ResultStatus.Should().Be(RequestErrorStatus.FailedToGetCCAMinimumPassesValue); ((TileRenderResponse)response).TileBitmapData.Should().BeNull(); } else { response.ResultStatus.Should().Be(RequestErrorStatus.OK); ((TileRenderResponse)response).TileBitmapData.Should().NotBeNull(); // Convert the response into a bitmap var bmp = SKBitmap.Decode(((TileRenderResponse)response).TileBitmapData); bmp.Should().NotBeNull(); bmp.Height.Should().Be(256); bmp.Width.Should().Be(256); if (!string.IsNullOrEmpty(fileName)) { using var image = SKImage.FromBitmap(bmp); using var data = image.Encode(SKEncodedImageFormat.Png, 100); using var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None); data.SaveTo(stream); } else { // If the comparison file does not exist then create it to provide a base comparison moving forward. if (!string.IsNullOrEmpty(compareToFile) && !File.Exists(compareToFile)) { using var image = SKImage.FromBitmap(bmp); using var data = image.Encode(SKEncodedImageFormat.Png, 100); using var stream = new FileStream(compareToFile, FileMode.Create, FileAccess.Write, FileShare.None); data.SaveTo(stream); } } if (!string.IsNullOrEmpty(compareToFile)) { var goodBmp = SKBitmap.Decode(compareToFile); goodBmp.Height.Should().Be(bmp.Height); goodBmp.Width.Should().Be(bmp.Width); for (var i = 0; i < bmp.Width; i++) { for (var j = 0; j < bmp.Height; j++) { if (goodBmp.GetPixel(i, j) != bmp.GetPixel(i, j)) { j = j; } goodBmp.GetPixel(i, j).Should().Be(bmp.GetPixel(i, j)); } } } } }