Beispiel #1
0
        public void PostProbeData_MissingInboundVehicle_Fails()
        {
            ProbeVehicleData probeData = new ProbeVehicleData();

            PositionSnapshot ps = new PositionSnapshot()
            {
                Accuracy   = 5,
                Altitude   = 123,
                Heading    = 180,
                Latitude   = 44.646581369493,
                Longitude  = -96.6830267664,
                Satellites = 0,
                Speed      = 14.77999305725097,
                TimeStamp  = 137349837631
            };

            probeData.Positions.Add(ps);

            using (IDbContext idtoFakeContext = new IDTOFakeContext())
                using (IUnitOfWork imuow = new UnitOfWork(idtoFakeContext))
                {
                    var mockTable = new Mock <IAzureTable <ProbeSnapshotEntry> >();
                    var cut       = new ProbeController(idtoFakeContext, mockTable.Object);

                    SetupControllerForTests(cut);

                    HttpResponseMessage returnMessage = cut.PostProbeData(probeData);

                    Assert.AreEqual(HttpStatusCode.BadRequest, returnMessage.StatusCode);
                }
        }
Beispiel #2
0
        public void PostProbeData_UpdateVehiclePosition_Success()
        {
            using (IDbContext idtoFakeContext = new IDTOFakeContext())
                using (IUnitOfWork imuow = new UnitOfWork(idtoFakeContext))
                {
                    AddTripToRepo(imuow);

                    LastVehiclePosition lvp = new LastVehiclePosition
                    {
                        VehicleName       = "MDT2",
                        PositionTimestamp = DateTime.UtcNow,
                        Latitude          = 44.646581369493,
                        Longitude         = -96.6830267664,
                        Speed             = 10,
                        Heading           = 180,
                        Accuracy          = 5
                    };

                    imuow.Repository <LastVehiclePosition>().Insert(lvp);
                    imuow.Save();

                    DateTime newestPositionTimestamp = DateTime.UtcNow.AddMinutes(1);
                    var      epoch           = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                    long     newestTimeStamp = Convert.ToInt64((newestPositionTimestamp - epoch).TotalMilliseconds);

                    ProbeVehicleData probeData = new ProbeVehicleData {
                        InboundVehicle = "MDT2"
                    };
                    PositionSnapshot ps = new PositionSnapshot()
                    {
                        Accuracy   = 5,
                        Altitude   = 123,
                        Heading    = 180,
                        Latitude   = 44.646581369493,
                        Longitude  = -96.6830267664,
                        Satellites = 0,
                        Speed      = 14.77999305725097,
                        TimeStamp  = newestTimeStamp
                    };
                    probeData.Positions.Add(ps);

                    var mockTable = new Mock <IAzureTable <ProbeSnapshotEntry> >();
                    var cut       = new ProbeController(idtoFakeContext, mockTable.Object);

                    SetupControllerForTests(cut);

                    HttpResponseMessage returnMessage = cut.PostProbeData(probeData);

                    List <LastVehiclePosition> lvpList = imuow.Repository <LastVehiclePosition>().Query().Get().Where(v => v.VehicleName == "MDT2").ToList();

                    Assert.AreEqual(1, lvpList.Count);
                    Assert.AreEqual(newestPositionTimestamp.ToLongTimeString(), lvpList.First().PositionTimestamp.ToLongTimeString());
                }
        }
        /*
         *
         */
        public MainWindow()
        {
            InitializeComponent();

            // start of custom code
            WriteToLog.write("---- System Start ----", string.Empty, true);
            debug = Config.ReadElement("Debug", "False", true).Equals("true", StringComparison.OrdinalIgnoreCase);

            // initialize the sub classes
            GameBoard     = new GameBoard(this);
            GameMap       = new GameMap(this);
            SRS           = new SRSController(this);
            LRS           = new LRSController(this);
            Warp          = new WarpController(this);
            Torpedoes     = new TorpedoController(this);
            Phasers       = new PhaserController(this);
            Shields       = new ShieldController(this);
            Impulse       = new ImpulseController(this);
            GameObjects   = new GameObjects(this);
            DamageControl = new DamageControl(this);
            StarBases     = new StarBaseController(this);
            Probes        = new ProbeController(this);

            // set up a new board and start the timer
            NewGame(8);
            CreateTimer();

            WriteToLog.write("Debug = " + debug.ToString());
            WriteToLog.ClearOldLogs();

            // set up the hotkeys
            rcImpulse.InputGestures.Add(new KeyGesture(Key.I, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcImpulse, ImpulseCommand));

            rcWarp.InputGestures.Add(new KeyGesture(Key.W, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcWarp, WarpCommand));

            rcTorpedoes.InputGestures.Add(new KeyGesture(Key.T, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcTorpedoes, TorpedoCommand));

            rcPhasers.InputGestures.Add(new KeyGesture(Key.P, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcPhasers, PhaserCommand));

            rcShields.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            CommandBindings.Add(new CommandBinding(rcShields, ShieldCommand));
        }