public void RenderFromInMemoryGraph() { const string graph = @"digraph G { node [style=filled, shape=rect] # Nodes ""String age"" -> ""Int64.Parse()"" -> {""Int64"", ""Collector""} # Formatting ""String age"" [color=green] ""Int64"" [color=""#9fbff4""] ""Int64.Parse()"" [shape=invhouse] ""Collector"" [color = ""#c361f4""] { rank=same; ""Int64.Parse()"", ""Collector""} }"; var graphViz = new GraphViz(); byte[] result = graphViz.LayoutAndRenderDotGraph(graph, "png"); Approvals.VerifyBinaryFile(result, ".png"); }
public async Task ReturnsBytesForUpdatedSnapshotAsync() { using (var fileContext = new TemporaryFilesContext("ReturnsBytesForUpdatedSnapshotAsync", false)) { var snapshot = new Snapshot(); snapshot.SetData("Data A", Encoding.UTF8.GetBytes("123")); snapshot.SetData("Large Data", LargeStringBytes); var bytes1 = await snapshot.GetAllBytesAsync(); // Now we update and we should have an updated byte array snapshot.SetData("Data A", Encoding.UTF8.GetBytes("123")); snapshot.SetData("Data B", Encoding.UTF8.GetBytes("456")); snapshot.SetData("Data C", Encoding.UTF8.GetBytes("789")); snapshot.SetData("Large Data", LargeStringBytes); var bytes2 = await snapshot.GetAllBytesAsync(); Assert.AreNotEqual(bytes1, bytes2); var outputFileName = fileContext.GetFile("snapshot.zip"); File.WriteAllBytes(outputFileName, bytes2); Approvals.VerifyBinaryFile(bytes2, "zip"); //Approvals.VerifyFile(outputFileName); } }
public void RenderFromGraphInFile() { const string graph = @"digraph G { node [style=filled, shape=rect] # Nodes ""String age"" -> ""Int64.Parse()"" -> {""Int64"", ""Collector""} # Formatting ""String age"" [color=green] ""Int64"" [color=""#9fbff4""] ""Int64.Parse()"" [shape=invhouse] ""Collector"" [color = ""#c361f4""] { rank=same; ""Int64.Parse()"", ""Collector""} }"; string inputFilePath = Path.Combine(Directory.GetCurrentDirectory(), "RenderFromInGraphInFile.dot"); File.WriteAllText(inputFilePath, graph); var graphViz = new GraphViz(); byte[] result = graphViz.LayoutAndRenderDotGraphFromFile(inputFilePath, "png"); Approvals.VerifyBinaryFile(result, ".png"); }
public void Write_WithSmallHeader_ReturnsExpectedResult() { var hdr = new ASCIIEncoding().GetBytes("short header"); var result = ObjectUnderTest.Write(TestHelpers.BlockExpectedResult, hdr); Approvals.VerifyBinaryFile(result, ".stl"); }
public void EnsureEncodedCorrectly() { var xMacSender = new MACAddress( new byte[] { 00, 0x50, 0x56, 0xc0, 0x00, 0x01 }); var xIPSender = new Address(192, 168, 17, 1); var xMacTarget = MACAddress.Broadcast; var xIPTarget = new Address(192, 168, 17, 102); var xArpTargetMac = new MACAddress(new byte[6]); var xPacket = new ARPRequest_Ethernet(xMacSender, xIPSender, xMacTarget, xIPTarget, xArpTargetMac); var xExpectedPacket = "FF FF FF FF FF FF 00 50 " + Environment.NewLine + "56 C0 00 01 08 06 00 01 " + Environment.NewLine + "08 00 06 04 00 01 00 50 " + Environment.NewLine + "56 C0 00 01 C0 A8 11 01 " + Environment.NewLine + "00 00 00 00 00 00 C0 A8 " + Environment.NewLine + "11 66"; Approvals.Verify(Utilities.PrettyPrint(xPacket.RawData)); Approvals.VerifyBinaryFile(xPacket.RawData, "bin"); Assert.AreEqual(xExpectedPacket, Utilities.PrettyPrint(xPacket.RawData)); }
public void Write_WithLargeHeader_ReturnsExpectedResult() { var hdr = string.Join("", Enumerable.Repeat("abcdefghijklmnopqrstuvwxyz1234567890", 10)); var hdrBytes = new ASCIIEncoding().GetBytes(hdr); var result = ObjectUnderTest.Write(TestHelpers.BlockExpectedResult, hdrBytes); Approvals.VerifyBinaryFile(result, ".stl"); }
private static void VerifyAsRenderedGraph(IGraphNode input, string format) { var dotGraph = DotGraph.DotGraph.FromPipeline(input); var graphViz = new GraphViz(); graphViz.Config.TreatWarningsAsErrors = true; var output = graphViz.LayoutAndRenderDotGraph(dotGraph.ToString(), format); Approvals.VerifyBinaryFile(output, "." + format); }
public void ContentApproval_Document() { // Arrange WebRequest request = WebRequest.Create(Localhost + "document.pdf"); // Act WebResponse response = request.GetResponse(); Stream receiveStream = response.GetResponseStream(); BinaryReader readStream = new BinaryReader(receiveStream, Encoding.UTF8); var requestContent = readStream.ReadBytes(Convert.ToInt32(response.ContentLength)); // Assert Approvals.VerifyBinaryFile(requestContent, "pdf"); }
public async Task Get_nuget_package_stream() { Stream?packageStream = await Fixture.Client.GetPackageAsync("Collections.NET", "1.7.0"); packageStream.ShouldNotBeNull(); await using var ms = new MemoryStream(); packageStream.Seek(0, SeekOrigin.Begin); await packageStream.CopyToAsync(ms); ms.Seek(0, SeekOrigin.Begin); Approvals.VerifyBinaryFile(ms.ToArray(), ".nupkg.zip"); }
public async Task ReturnsBytesForEmptySnapshotAsync() { using (var fileContext = new TemporaryFilesContext("ReturnsBytesForEmptySnapshotAsync", false)) { var snapshot = new Snapshot(); var bytes = await snapshot.GetAllBytesAsync(); var outputFileName = fileContext.GetFile("snapshot.zip"); File.WriteAllBytes(outputFileName, bytes); Approvals.VerifyBinaryFile(bytes, "zip"); //Approvals.VerifyFile(outputFileName); } }
public async Task ReturnsBytesForSnapshotAsync() { using (var fileContext = new TemporaryFilesContext("ReturnsBytesForSnapshotAsync", false)) { var snapshot = new Snapshot(); snapshot.SetData("Data A", Encoding.UTF8.GetBytes("123")); snapshot.SetData("Data B", Encoding.UTF8.GetBytes("456")); snapshot.SetData("Data C", Encoding.UTF8.GetBytes("789")); snapshot.SetData("Large Data", LargeStringBytes); var bytes = await snapshot.GetAllBytesAsync(); var outputFileName = fileContext.GetFile("snapshot.zip"); File.WriteAllBytes(outputFileName, bytes); Approvals.VerifyBinaryFile(bytes, "zip"); //Approvals.VerifyFile(outputFileName); } }
public void TestBytes() { var path = PathUtilities.GetDirectoryForCaller(); Approvals.VerifyBinaryFile(File.ReadAllBytes(path + "a.png"), "png"); }
public void Write_WithBlock_ReturnsExpectedResult() { var result = ObjectUnderTest.Write(TestHelpers.BlockExpectedResult); Approvals.VerifyBinaryFile(result, ".stl"); }
public static void VerifySnapshot(this UIElement source, Size size) { Approvals.VerifyBinaryFile(source.TakeSnapshot(size), ".png"); }