public void Slew_Minus_StopsWhenReachsMinus90()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();
            controller.Position = -80;

            var slewTime = TimeSpan.FromSeconds(20 / (Constants.DEGREES_PER_SECOND * 8));
            var task     = controller.Slew(Orientation.Minus, slewTime);

            //Simulate time ticking by
            slewTime = TimeSpan.FromSeconds(5 / (Constants.DEGREES_PER_SECOND * 8));
            fakeTelescope.SiderealTime += slewTime.TotalHours;
            Thread.Sleep(20);
            fakeTelescope.SiderealTime += slewTime.TotalHours;
            Thread.Sleep(20);
            fakeTelescope.SiderealTime += slewTime.TotalHours;
            Thread.Sleep(20);
            fakeTelescope.SiderealTime += slewTime.TotalHours;
            Thread.Sleep(20);

            task.Wait();
            Assert.AreEqual(-90, controller.Position);
        }
        public void Slew_Plus_StartsTrackingPosition()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();

            var task = controller.Slew(Orientation.Plus, TimeSpan.FromSeconds(10));

            fakeTelescope.SiderealTime += TimeSpan.FromSeconds(10).TotalHours;

            task.Wait();
            Assert.AreEqual(Math.Round((Constants.DEGREES_PER_SECOND * 8) * 10, 4), Math.Round(controller.Position, 4));
        }
        public void StartStopSlew_Minus_SetsSlewing()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();

            controller.StartSlew(Orientation.Minus);

            Assert.IsTrue(controller.Slewing);

            controller.StopSlew();

            Assert.IsFalse(controller.Slewing);
        }
        public void StartStopSlew_Minus_SetsSlewRate()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();

            controller.StartSlew(Orientation.Minus);

            Assert.AreEqual(-8, controller.SlewRate);

            controller.StopSlew();

            Assert.AreEqual(0, controller.SlewRate);
        }
        public void Slew_Minus_PositionUpdatesAtSlewRateNegativeStart()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();
            controller.Position = -50;

            var task = controller.Slew(Orientation.Minus, TimeSpan.FromSeconds(10));

            fakeTelescope.SiderealTime += TimeSpan.FromSeconds(10).TotalHours;

            task.Wait();
            Assert.AreEqual(Math.Round(-50 - (Constants.DEGREES_PER_SECOND * 8) * 10, 4), Math.Round(controller.Position, 4));
        }
        public void Slew_Plus_ReturnsToNotMovingAfterSlew()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();
            controller.Position = TimeSpan.FromSeconds(180).TotalHours;

            var task = controller.Slew(Orientation.Plus, TimeSpan.FromSeconds(10));

            Assert.AreEqual(8, controller.SlewRate);
            fakeTelescope.SiderealTime += TimeSpan.FromSeconds(10).TotalHours;

            task.Wait();
            Assert.AreEqual(0, controller.SlewRate);
        }
        public void Slew_Plus_SetsSlewing()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new DecAxisController(fakeTelescope);

            controller.Connect();

            var task = controller.Slew(Orientation.Plus, TimeSpan.FromSeconds(10));

            Assert.IsTrue(controller.Slewing);

            fakeTelescope.SiderealTime += TimeSpan.FromSeconds(10).TotalHours;

            task.Wait();
            Assert.IsFalse(controller.Slewing);
        }