using Microsoft.VisualStudio.TestTools.UnitTesting;
using NavisworksTransport.Utils.CoordinateSystem;
using System.Numerics;

namespace NavisworksTransport.UnitTests.CoordinateSystem
{
    [TestClass]
    public class ProjectReferenceFrameTests
    {
        [TestMethod]
        public void DefaultForYUp_ShouldUseCanonicalUpAndYUpModelConvention()
        {
            ProjectReferenceFrame frame = ProjectReferenceFrame.CreateDefault(CoordinateSystemType.YUp);

            Assert.AreEqual(0.0, frame.SphereCenterInCanonical3.X, 1e-9);
            Assert.AreEqual(0.0, frame.SphereCenterInCanonical3.Y, 1e-9);
            Assert.AreEqual(0.0, frame.SphereCenterInCanonical3.Z, 1e-9);
            Assert.AreEqual(0.0, frame.ProjectUpInCanonical3.X, 1e-9);
            Assert.AreEqual(0.0, frame.ProjectUpInCanonical3.Y, 1e-9);
            Assert.AreEqual(1.0, frame.ProjectUpInCanonical3.Z, 1e-9);
            Assert.AreEqual(LocalAxisDirection.PositiveX, frame.DefaultModelAxisConvention.ForwardAxis);
            Assert.AreEqual(LocalAxisDirection.PositiveY, frame.DefaultModelAxisConvention.UpAxis);
        }

        [TestMethod]
        public void Constructor_ShouldNormalizeProjectUp()
        {
            var frame = new ProjectReferenceFrame(
                new Vector3(1, 2, 3),
                new Vector3(0, 0, 10),
                ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.ZUp));

            Assert.AreEqual(0.0, frame.ProjectUpInCanonical3.X, 1e-9);
            Assert.AreEqual(0.0, frame.ProjectUpInCanonical3.Y, 1e-9);
            Assert.AreEqual(1.0, frame.ProjectUpInCanonical3.Z, 1e-9);
        }
    }
}
