/// <summary> /// Tests the save method. /// </summary> private void TestSaveMethod(string filePath) { ModelFile modelFile = new ModelFile(); modelFile.Load(filePath); MemoryStream savedStream = new MemoryStream(); modelFile.Save(savedStream); savedStream.Seek(0, SeekOrigin.Begin); ModelFile savedModelFile = new ModelFile(); savedModelFile.Load(savedStream); savedStream.Close(); Assert.AreEqual(modelFile.Pool, savedModelFile.Pool, "Pool values do not match"); Assert.AreEqual(modelFile.BoneTable.Count, savedModelFile.BoneTable.Count, "Bone table counts do not match"); for (int i = 0; i < modelFile.BoneTable.Count; i++) { Assert.AreEqual(modelFile.BoneTable[i], savedModelFile.BoneTable[i], "Bone table values do not match"); } Assert.AreEqual(modelFile.Vertices.Count, savedModelFile.Vertices.Count, "Vertex counts do not match"); for (int i = 0; i < modelFile.Vertices.Count; i++) { Assert.AreEqual(modelFile.Vertices[i].Position, savedModelFile.Vertices[i].Position, "Vertex position values do not match"); Assert.AreEqual(modelFile.Vertices[i].Normal, savedModelFile.Vertices[i].Normal, "Vertex normal values do not match"); Assert.AreEqual(modelFile.Vertices[i].Colour, savedModelFile.Vertices[i].Colour, "Vertex colour values do not match"); Assert.AreEqual(modelFile.Vertices[i].BoneWeights, savedModelFile.Vertices[i].BoneWeights, "Vertex bone weight values do not match"); Assert.AreEqual(modelFile.Vertices[i].BoneIndices, savedModelFile.Vertices[i].BoneIndices, "Vertex bone index values do not match"); Assert.AreEqual(modelFile.Vertices[i].TextureCoordinates[0], savedModelFile.Vertices[i].TextureCoordinates[0], "Vertex texture coordinate values do not match"); Assert.AreEqual(modelFile.Vertices[i].TextureCoordinates[1], savedModelFile.Vertices[i].TextureCoordinates[1], "Vertex texture coordinate values do not match"); Assert.AreEqual(modelFile.Vertices[i].TextureCoordinates[2], savedModelFile.Vertices[i].TextureCoordinates[2], "Vertex texture coordinate values do not match"); Assert.AreEqual(modelFile.Vertices[i].TextureCoordinates[3], savedModelFile.Vertices[i].TextureCoordinates[3], "Vertex texture coordinate values do not match"); Assert.AreEqual(modelFile.Vertices[i].Tangent, savedModelFile.Vertices[i].Tangent, "Vertex tangent values do not match"); } Assert.AreEqual(modelFile.Indices.Count, savedModelFile.Indices.Count, "Index counts do not match"); for (int i = 0; i < modelFile.Indices.Count; i++) { Assert.AreEqual(modelFile.Indices[i], savedModelFile.Indices[i], "Index values do not match"); } Assert.AreEqual(modelFile.Materials.Count, savedModelFile.Materials.Count, "Material counts do not match"); for (int i = 0; i < modelFile.Materials.Count; i++) { Assert.AreEqual(modelFile.Materials[i], savedModelFile.Materials[i], "Material values do not match"); } Assert.AreEqual(modelFile.Strips.Count, savedModelFile.Strips.Count, "Strip counts do not match"); for (int i = 0; i < modelFile.Strips.Count; i++) { Assert.AreEqual(modelFile.Strips[i], savedModelFile.Strips[i], "Strip values do not match"); } }