public void WriteString() { STLDocument stl1 = new STLDocument("WriteString", new List <Facet>() { new Facet(new Normal(0.23f, 0, 1), new List <Vertex>() { new Vertex(0, 0, 0), new Vertex(-10.123f, -10, 0), new Vertex(-10.123f, 0, 0) }, 0) }); STLDocument stl2 = null; byte[] stl1Data = null; string stl1String = null; byte[] stl2Data = null; string stl2String = null; using (MemoryStream stream = new MemoryStream()) { stl1.WriteText(stream); stl1Data = stream.ToArray(); stl1String = Encoding.ASCII.GetString(stl1Data); } using (MemoryStream stream = new MemoryStream(stl1Data)) { stl2 = STLDocument.Read(stream); stl2Data = stream.ToArray(); stl2String = Encoding.ASCII.GetString(stl2Data); } Assert.IsTrue(stl1.Equals(stl2)); Assert.AreEqual(stl1String, stl2String); }
public void WriteText__ToStream__Then__Read__FromStream__ProducesSameDocument() { STLDocument stl1 = new STLDocument("WriteString", new List <Facet>() { new Facet(new Normal(0.23f, 0, 1), new List <Vertex>() { new Vertex(0, 0, 0), new Vertex(-10.123f, -10, 0), new Vertex(-10.123f, 0, 0) }, 0) }); STLDocument stl2; byte[] stl1Data; string stl1String; byte[] stl2Data; string stl2String; using (var stream = new MemoryStream()) { stl1.WriteText(stream); stl1Data = stream.ToArray(); stl1String = Encoding.ASCII.GetString(stl1Data); } using (var stream = new MemoryStream(stl1Data)) { stl2 = STLDocument.Read(stream); stl2Data = stream.ToArray(); stl2String = Encoding.ASCII.GetString(stl2Data); } CompareSTLs(stl1, stl2); Assert.Equal(stl1String, stl2String); }
public void WriteString() { STLDocument stl1 = new STLDocument("WriteString", new List<Facet>() { new Facet(new Normal( 0, 0, 1), new List<Vertex>() { new Vertex( 0, 0, 0), new Vertex(-10, -10, 0), new Vertex(-10, 0, 0) }, 0) }); STLDocument stl2 = null; byte[] stl1Data = null; string stl1String = null; byte[] stl2Data = null; string stl2String = null; using (MemoryStream stream = new MemoryStream()) { stl1.WriteText(stream); stl1Data = stream.ToArray(); stl1String = Encoding.ASCII.GetString(stl1Data); } using (MemoryStream stream = new MemoryStream(stl1Data)) { stl2 = STLDocument.Read(stream); stl2Data = stream.ToArray(); stl2String = Encoding.ASCII.GetString(stl2Data); } Assert.IsTrue(stl1.Equals(stl2)); Assert.AreEqual(stl1String, stl2String); }