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

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

            controller.Slew(Orientation.Plus, TimeSpan.FromSeconds(10));
        }
        public void Slew_Plus_ReturnsToTrackingRateAfterSlew()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new RAAxisController(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(1, controller.SlewRate);
        }
        public void Slew_Plus_SetsSlewing()
        {
            var fakeTelescope = new FakeTelescope();

            fakeTelescope.SiderealTime = TimeSpan.FromHours(3).TotalHours;
            var controller = new RAAxisController(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);
        }
        public void Slew_Plus_PositionUpdatesAtSlewRate()
        {
            var fakeTelescope = new FakeTelescope();

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

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

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

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

            task.Wait();
            var location = TimeSpan.FromHours(controller.Position);

            Assert.AreEqual(260, Math.Round(location.TotalSeconds));
        }
        public void Slew_Plus_ReturnsToEndOfDatWhenPassed0()
        {
            var fakeTelescope = new FakeTelescope();

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

            controller.Connect();
            controller.Position = 0;

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

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

            task.Wait();
            var location = TimeSpan.FromHours(controller.Position);

            Assert.AreEqual(Math.Round(TimeSpan.FromHours(Constants.HOURS_PER_SIDEREAL_DAY - (TimeSpan.FromSeconds(80).TotalHours)).TotalSeconds), Math.Round(location.TotalSeconds));
        }