コード例 #1
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);
        }
コード例 #2
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());
        }
コード例 #3
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);
        }