using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MEMS_Visualizer;
using System.Windows;
using System.Windows.Media.Media3D;
using System.IO;

namespace MEMS_Visualizer_Tests
{
    [TestClass]
    public class FileLoaderTests
    {
        [TestMethod]
        public void loadData_WithValidData()
        {
            string testPath = @"c:\temp\MyTest.txt";

            Vector3D[] testVectors = {
                                         new Vector3D(0.0, 0.0, 0.0),
                                         new Vector3D(1.0, 1.0, 1.0)
                                     };

            string[] lines = {
                                 testVectors[0].ToString(),
                                 testVectors[1].ToString()
                             };

            File.WriteAllLines(testPath, lines);

            MovementData testData = new MovementData();
            FileLoader testFileLoader = new FileLoader(testPath, testData);

            int i = 0;
            foreach (Vector3D vector in testData.HandRotationSequence)
            {
                Assert.AreEqual(testVectors[i].X, vector.X, 0.0001,
                    "File was not read properly." + testVectors[i].X + " != " + vector.X);
                Assert.AreEqual(testVectors[i].Y, vector.Y, 0.0001,
                    "File was not read properly." + testVectors[i].Y + " != " + vector.Y);
                Assert.AreEqual(testVectors[i].Z, vector.Z, 0.0001,
                    "File was not read properly." + testVectors[i].Z + " != " + vector.Z);
                i++;
            }
        }
    }
}
