public void ReadWrite(string modelPath) { // Arrange var reader = new StlBinaryContentReader(); var writer = new StlBinaryContentWriter(); var file = File.ReadAllBytes(modelPath); var stream = new MemoryStream(file); // Act var input = reader.Read(stream); var output = writer.Write(input); // Assert Assert.Equal(file.Length, output.Length); }
public void Read(string modelPath, int expectedVertices, int expectedIndicies) { // Arrange var reader = new StlBinaryContentReader(); var file = File.ReadAllBytes(modelPath); var stream = new MemoryStream(file); // Act var result = reader.Read(stream); // Assert Assert.Null(result.Name); Assert.Equal(expectedVertices, result.Vertices.Length); Assert.Equal(expectedIndicies, result.Indices.Length); Assert.Equal(Vector4.One, result.Color); }
public void Write_Operation_Subtract() { // Arrange var reader = new StlBinaryContentReader(); var writer = new StlBinaryContentWriter(); var file = File.ReadAllBytes("./assets/models/shape_operation_subtract.stl"); var stream = new MemoryStream(file); var input = reader.Read(stream); // Act var shape1 = new Cube(new Vector3(0, 0, 0), new Vector3(1, 1, 1)); var shape2 = new Cube(new Vector3(0.8f, 0.8f, 0), new Vector3(1, 1, 1)); var shape = shape1.Do(ShapeOperation.Subtract, shape2); var output = writer.Write(shape); // Assert Assert.Equal(file.Length, output.Length); Assert.Null(input.Name); Assert.Equal(input.Vertices.Length, shape.Vertices.Length); Assert.Equal(input.Indices.Length, shape.Indices.Length); }