Exemplo n.º 1
0
        public void BadCollection()
        {
            var cdb = new CosmosDB();
            var act = ActorOf(CosmosSaveActor.Props(cdb));

            act.Tell(new CosmosSaveActor.SaveRequest(new { id = 1 }, null), TestActor);
            ExpectMsg <CosmosSaveActor.BadRequest>(TimeSpan.FromSeconds(10));
        }
Exemplo n.º 2
0
        public void BadObjectToSave()
        {
            var cdb = new CosmosDB();
            var act = ActorOf(CosmosSaveActor.Props(cdb));

            act.Tell(new CosmosSaveActor.SaveRequest(null, null), TestActor);
            ExpectMsg <CosmosSaveActor.BadRequest>(TimeSpan.FromSeconds(5));
        }
Exemplo n.º 3
0
        public void StartUpActor()
        {
            var cdb  = new CosmosDB();
            var save = ActorOf(CosmosSaveActor.Props(cdb));
            var icao = ActorOf <ICAOLookupActor>();
            var a    = ActorOf(FlightActor.Props());

            a.Tell(new FlightActor.FlightActorInit(save, "123", icao), TestActor);
            ExpectNoMsg(TimeSpan.FromSeconds(5));
        }
Exemplo n.º 4
0
        public void SubmitMany()
        {
            // resources for actor
            var cdb = new CosmosDB();

            cdb.OpenConnection();
            var save = ActorOf(CosmosSaveActor.Props(cdb));
            var icao = ActorOf <ICAOLookupActor>();

            // test data
            var data = getTestData();

            DeviceReading dr = data[0];
            FlightData    fd = dr.aircraft.First(z => z.flight != null && z.flight.Trim() == "JBU238");

            var flight = fd.flight.Trim();
            var str    = "activeSnap:" + flight.Trim();

            var a = ActorOf(FlightActor.Props());

            a.Tell(new FlightActor.FlightActorInit(save, flight.Trim(), icao), TestActor);

            System.Threading.Thread.Sleep(1000);

            data = data.OrderBy(z => z.now).ToList();

            foreach (var d in data.Take(2))
            {
                if (d.aircraft.Any(z => z.flight != null && z.flight.Trim() == flight))
                {
                    fd = d.aircraft.First(z => z.flight != null && z.flight.Trim() == flight);
                    dr = d;
                    a.Tell(new FlightActor.FlightDataRequest()
                    {
                        deviceId   = d.deviceId,
                        flightData = fd,
                        now        = d.now
                    }, TestActor);
                }
            }

            ExpectNoMsg(TimeSpan.FromSeconds(5));

            var res = cdb.GetDocumentQuery <FlightDataSnapshot>("flights")
                      .Where(z => z.id == str && z.flight == flight.Trim())
                      .OrderByDescending(z => z.now)
                      .ToList();

            Assert.Greater(res.Count, 0);

            var m = data.Where(z => z.now == res[0].now);

            Assert.AreEqual(res.First().now, dr.now);
            Assert.AreEqual(res.First().lat, fd.lat);
        }
Exemplo n.º 5
0
        public void GoodSave()
        {
            var cdb = new CosmosDB();

            // clear out test document
            cdb.DeleteDocument("system", "1", "1");

            // do test
            var act = ActorOf(CosmosSaveActor.Props(cdb));

            act.Tell(new CosmosSaveActor.SaveRequest(new { id = "1", name = "test" }, "system"), TestActor);
            ExpectNoMsg(TimeSpan.FromSeconds(10));

            // check the DB
            var vals = cdb
                       .GetDocumentQuery("system", "select * from c where c.id = '1'")
                       .ToList();

            Assert.IsTrue(vals.Any());
        }
Exemplo n.º 6
0
        public void SubmitNullFlightData()
        {
            // resources for actor
            var cdb = new CosmosDB();

            cdb.OpenConnection();
            var save = ActorOf(CosmosSaveActor.Props(cdb));
            var icao = ActorOf <ICAOLookupActor>();

            var a = ActorOf(FlightActor.Props());

            a.Tell(new FlightActor.FlightActorInit(save, "TEST", icao), TestActor);
            Watch(a);
            a.Tell(new FlightActor.FlightDataRequest()
            {
                deviceId   = "TEST",
                flightData = null,
                now        = DateTimeOffset.Now.ToUnixTimeMilliseconds()
            }, TestActor);

            ExpectTerminated(a, TimeSpan.FromSeconds(5));
        }
Exemplo n.º 7
0
        public void SubmitOne()
        {
            // resources for actor
            var cdb = new CosmosDB();

            cdb.OpenConnection();
            var save = ActorOf(CosmosSaveActor.Props(cdb));
            var icao = ActorOf <ICAOLookupActor>();

            // test data
            var data = getTestData();
            var info = data[0];
            var tf   = info.aircraft.First(z => z.flight != null);
            var str  = "activeSnap:" + tf.flight.Trim();

            var a = ActorOf(FlightActor.Props());

            a.Tell(new FlightActor.FlightActorInit(save, tf.flight, icao), TestActor);

            a.Tell(new FlightActor.FlightDataRequest()
            {
                deviceId   = info.deviceId,
                flightData = tf,
                now        = info.now
            }, TestActor);

            ExpectNoMsg(TimeSpan.FromSeconds(5));

            var res = cdb.GetDocumentQuery <FlightDataSnapshot>("flights")
                      .Where(z => z.id == str)
                      .ToList();

            Assert.Greater(res.Count, 0);

            Assert.AreEqual(res[0].now, info.now);
            Assert.AreEqual(res[0].lat, tf.lat);
        }