Ejemplo n.º 1
0
        public void Matrix_Serialize_Test()
        {
            string path = Path.Combine(BaseSerialization.GetPath(GetType()), "matrix_serialize_test.json");

            Matrix m1 = new[, ] {
                { System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2, System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2 },
                { System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2, System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2 },
                { System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2, System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2 },
                { System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2, System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2 },
                { System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2, System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2 }
            };

            // serialize
            // ensure we delete the file first or we may have extra data
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            m1.Save(path);

            // deserialize
            Matrix m2 = Matrix.Load(path);

            Assert.Equal(m1, m2);
        }
Ejemplo n.º 2
0
        public void Vector_Serialize_Test()
        {
            string path = Path.Combine(BaseSerialization.GetPath(GetType()), "vector_serialize_test.json");

            // want to test "ugly" members in the vector
            Vector v1 = new[] { System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2, System.Math.PI, System.Math.PI / 2.3, System.Math.PI * 1.2 };

            // serialize
            // ensure we delete the file first
            // or we may have extra data
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            v1.Save(path);

            // deserialize
            Vector v2 = Vector.Load(path);

            Assert.Equal(v1, v2);
        }