public void TestSingleTripStartOrStopQueryAfterUpdateMessage()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(36, 121),
                                                                                           new GeoPoint(38, 123)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(0));
            totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(38, 123),
                                                                                           new GeoPoint(40, 125)));
            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(0));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(0));
        }
        public void TestStartsAndStopsInGeoRectStartOrStopQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 38,
                Longitude = 123,
                TripId    = 432
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(36, 121),
                                                                                           new GeoPoint(39, 124)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(25));
        }
        public void TestSingleTripThroughGeoRectQueryAfterUpdateMessage()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(36, 121), new GeoPoint(38, 123)));

            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(38, 123), new GeoPoint(40, 125)));
            Assert.That(totalTrips, Is.EqualTo(1));
        }
        public void TestSingleTripPointInTimeQueryAfterUpdateMessage()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            var totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673020);

            Assert.That(totalTrips, Is.EqualTo(0));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673030);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673040);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673070);
            Assert.That(totalTrips, Is.EqualTo(1));
        }
 private static void InsertTripMessageWithMissingEvent()
 {
     TripMessageBl.InsertTripMessage(new TripMessage
     {
         Epoch     = 1392864673030,
         Latitude  = 37.79947m,
         Longitude = 122.51163m,
         TripId    = 432
     });
 }
 private static void InsertTripMessageWithMissingLongitude()
 {
     TripMessageBl.InsertTripMessage(new TripMessage
     {
         Event    = TripEvent.Begin,
         Epoch    = 1392864673030,
         Latitude = 37.79947m,
         TripId   = 432
     });
 }
 private static void InsertTripMessageWithInvalidEpoch()
 {
     TripMessageBl.InsertTripMessage(new TripMessage
     {
         Event     = TripEvent.Begin,
         Epoch     = 0,
         Latitude  = 37.79947m,
         Longitude = 122.51163m,
         TripId    = 432
     });
 }
 private static void InsertTripMessageWithInvalidTripId()
 {
     TripMessageBl.InsertTripMessage(new TripMessage
     {
         Event     = TripEvent.Begin,
         Epoch     = 1392864673030,
         Latitude  = 37.79947m,
         Longitude = 122.51163m,
         TripId    = 0
     });
 }
 private static void InsertNonBeginTripMessageThatDoesNotExist()
 {
     TripMessageBl.InsertTripMessage(new TripMessage
     {
         Event     = TripEvent.Update,
         Epoch     = 1392864673030,
         Latitude  = 37.79947m,
         Longitude = 122.51163m,
         TripId    = 432
     });
 }
 private static void InsertNonEndTripMessageWithFare()
 {
     TripMessageBl.InsertTripMessage(new TripMessage
     {
         Event     = TripEvent.Begin,
         Epoch     = 1392864673030,
         Fare      = 25,
         Latitude  = 37.79947m,
         Longitude = 122.51163m,
         TripId    = 432
     });
 }
        public void TestMultipleTripsStartOrStopQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 110,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 50,
                Latitude  = 50,
                Longitude = 130,
                TripId    = 433
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(29, 109),
                                                                                           new GeoPoint(31, 111)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(25));
            totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(49, 129),
                                                                                           new GeoPoint(51, 131)));
            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(50));
            totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(39, 119),
                                                                                           new GeoPoint(41, 121)));
            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(2));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(75));
        }
        private static void InsertBeginTripMessageThatAlreadyExists()
        {
            var tripMessage = new TripMessage
            {
                Event     = TripEvent.Begin,
                Epoch     = 1392864673030,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            TripMessageBl.InsertTripMessage(tripMessage);
        }
Exemplo n.º 13
0
        private static TripMessage InsertUpdateMessage()
        {
            var tripMessage = new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            return(tripMessage);
        }
        public void TestTripOnCornerThroughGeoRectQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 120,
                TripId    = 432
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(30, 120), new GeoPoint(40, 130)));

            Assert.That(totalTrips, Is.EqualTo(1));
        }
        private static void InsertTripMessageThatAlreadyHasMessageAfterEpoch()
        {
            var tripMessage = new TripMessage
            {
                Event     = TripEvent.Begin,
                Epoch     = 1392864673030,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            tripMessage.Epoch = 1392864673020;
            tripMessage.Event = TripEvent.Update;
            TripMessageBl.InsertTripMessage(tripMessage);
        }
        public void TestMultipleTripsThroughGeoRectQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 110,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 50,
                Latitude  = 50,
                Longitude = 130,
                TripId    = 433
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(29, 109), new GeoPoint(31, 111)));

            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(49, 129), new GeoPoint(51, 131)));
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(39, 119), new GeoPoint(41, 121)));
            Assert.That(totalTrips, Is.EqualTo(2));
        }
        public void TestTripOnCornerStartOrStopQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 120,
                TripId    = 432
            });
            var totalTripsAndFares =
                TripBl.GetTotalTripsAndFaresThatStartOrStopInGeoRectangle(new GeoRectangle(new GeoPoint(30, 120),
                                                                                           new GeoPoint(40, 130)));

            Assert.That((int)totalTripsAndFares.TotalTrips, Is.EqualTo(1));
            Assert.That((decimal)totalTripsAndFares.TotalFares, Is.EqualTo(0));
        }
Exemplo n.º 18
0
        private Response AddTripMessage(dynamic parameters)
        {
            Response response;

            try
            {
                TripMessageBl.InsertTripMessage(GetTripMessage());
                response = new Response {
                    StatusCode = HttpStatusCode.Created
                };
            }
            catch (Exception ex)
            {
                response             = GetErrorMessage(ex);
                response.ContentType = "application/json";
                response.StatusCode  = HttpStatusCode.BadRequest;
            }
            return(response);
        }
        private static void InsertTripMessageThatAlreadyEnded()
        {
            var tripMessage = new TripMessage
            {
                Event     = TripEvent.Begin,
                Epoch     = 1392864673030,
                Latitude  = 37.79947m,
                Longitude = 122.51163m,
                TripId    = 432
            };

            TripMessageBl.InsertTripMessage(tripMessage);
            tripMessage.Epoch = 1392864673070;
            tripMessage.Fare  = 25;
            tripMessage.Event = TripEvent.End;
            TripMessageBl.InsertTripMessage(tripMessage);
            tripMessage.Epoch = 1392864673080;
            tripMessage.Event = TripEvent.Update;
            tripMessage.Fare  = null;
            TripMessageBl.InsertTripMessage(tripMessage);
        }
        public void TestEntireTripContainedInGeoRectThroughGeoRectQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 37,
                Longitude = 122,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 38,
                Longitude = 123,
                TripId    = 432
            });
            var totalTrips =
                TripBl.GetTotalTripsThroughGeoRectangle(new GeoRectangle(new GeoPoint(36, 121), new GeoPoint(39, 124)));

            Assert.That(totalTrips, Is.EqualTo(1));
        }
        public void TestMultipleTripPointInTimeQuery()
        {
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673030,
                Event     = TripEvent.Begin,
                Latitude  = 30,
                Longitude = 110,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.End,
                Fare      = 25,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 432
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673040,
                Event     = TripEvent.Begin,
                Latitude  = 40,
                Longitude = 120,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673070,
                Event     = TripEvent.Update,
                Latitude  = 39,
                Longitude = 124,
                TripId    = 433
            });
            TripMessageBl.InsertTripMessage(new TripMessage
            {
                Epoch     = 1392864673080,
                Event     = TripEvent.End,
                Fare      = 50,
                Latitude  = 50,
                Longitude = 130,
                TripId    = 433
            });
            var totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673020);

            Assert.That(totalTrips, Is.EqualTo(0));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673030);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673040);
            Assert.That(totalTrips, Is.EqualTo(2));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673070);
            Assert.That(totalTrips, Is.EqualTo(2));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673080);
            Assert.That(totalTrips, Is.EqualTo(1));
            totalTrips = TripBl.GetTotalTripsOccuringAtTime(1392864673090);
            Assert.That(totalTrips, Is.EqualTo(0));
        }