예제 #1
0
        public void DeleteGeofence_HappyPath()
        {
            DateTime firstCreatedUtc     = new DateTime(2017, 1, 1, 2, 30, 3);
            var      geofenceUid         = Guid.NewGuid();
            var      userUid             = Guid.NewGuid();
            var      geofenceType        = GeofenceType.Filter;
            var      createGeofenceEvent = new CreateGeofenceEvent
            {
                CustomerUID  = Guid.NewGuid(),
                UserUID      = userUid,
                GeofenceUID  = geofenceUid,
                GeofenceName = "Boundary one",
                GeofenceType = geofenceType.ToString(),
                GeometryWKT  = "POLYGON((80.257874 12.677856,79.856873 13.039345,80.375977 13.443052,80.257874 12.677856))",
                ActionUTC    = firstCreatedUtc
            };

            var deleteGeofenceEvent = new DeleteGeofenceEvent
            {
                GeofenceUID = geofenceUid,
                UserUID     = userUid,
                ActionUTC   = firstCreatedUtc
            };

            this.GeofenceRepo.StoreEvent(createGeofenceEvent).Wait();

            WriteEventToDb(deleteGeofenceEvent, "Geofence event not deleted");

            var g = this.GeofenceRepo.GetGeofence(geofenceUid.ToString());

            g.Wait();
            Assert.IsNull(g.Result, "Should not be able to retrieve geofence from geofenceRepo");
        }
예제 #2
0
        public void CreateGeofence_HappyPath()
        {
            DateTime firstCreatedUtc     = new DateTime(2017, 1, 1, 2, 30, 3);
            var      geofenceType        = GeofenceType.Filter;
            var      createGeofenceEvent = new CreateGeofenceEvent
            {
                CustomerUID  = Guid.NewGuid(),
                UserUID      = Guid.NewGuid(),
                GeofenceUID  = Guid.NewGuid(),
                GeofenceName = "Boundary one",
                GeofenceType = geofenceType.ToString(),
                GeometryWKT  = "POLYGON((80.257874 12.677856,79.856873 13.039345,80.375977 13.443052,80.257874 12.677856))",
                ActionUTC    = firstCreatedUtc
            };

            var boundary = new Geofence
            {
                CustomerUID     = createGeofenceEvent.CustomerUID.ToString(),
                UserUID         = createGeofenceEvent.UserUID.ToString(),
                GeofenceUID     = createGeofenceEvent.GeofenceUID.ToString(),
                Name            = createGeofenceEvent.GeofenceName,
                GeofenceType    = geofenceType,
                GeometryWKT     = createGeofenceEvent.GeometryWKT,
                LastActionedUTC = createGeofenceEvent.ActionUTC
            };

            WriteEventToDb(createGeofenceEvent, "Geofence event not written");

            var g = this.GeofenceRepo.GetGeofence(createGeofenceEvent.GeofenceUID.ToString());

            g.Wait();
            Assert.IsNotNull(g.Result, "Unable to retrieve geofence from geofenceRepo");
            //Note: cannot compare objects as Geofence has nullables while CreateGeofenceEvent doesn't
            Assert.AreEqual(boundary.CustomerUID, g.Result.CustomerUID, "Wrong CustomerUID");
            Assert.AreEqual(boundary.UserUID, g.Result.UserUID, "Wrong UserUID");
            Assert.AreEqual(boundary.GeofenceUID, g.Result.GeofenceUID, "Wrong GeofenceUID");
            Assert.AreEqual(boundary.Name, g.Result.Name, "Wrong Name");
            Assert.AreEqual(boundary.GeofenceType, g.Result.GeofenceType, "Wrong GeofenceType");
            Assert.AreEqual(boundary.GeometryWKT, g.Result.GeometryWKT, "Wrong GeometryWKT");
        }
예제 #3
0
        public void GetGeofences_HappyPath()
        {
            var custUid = Guid.NewGuid();
            var userId  = Guid.NewGuid();

            DateTime firstCreatedUtc = new DateTime(2017, 1, 1, 2, 30, 3);
            var      geofenceType    = GeofenceType.Filter.ToString();

            var createGeofenceEvent1 = new CreateGeofenceEvent
            {
                CustomerUID  = custUid,
                UserUID      = userId,
                GeofenceUID  = Guid.NewGuid(),
                GeofenceName = "Boundary one",
                GeofenceType = geofenceType,
                GeometryWKT  = "POLYGON((80.257874 12.677856,79.856873 13.039345,80.375977 13.443052,80.257874 12.677856))",
                ActionUTC    = firstCreatedUtc
            };
            var createGeofenceEvent2 = new CreateGeofenceEvent
            {
                CustomerUID  = custUid,
                UserUID      = userId,
                GeofenceUID  = Guid.NewGuid(),
                GeofenceName = "Boundary two",
                GeofenceType = geofenceType,
                GeometryWKT  = "POLYGON((81.257874 13.677856,80.856873 14.039345,81.375977 14.443052,81.257874 13.677856))",
                ActionUTC    = firstCreatedUtc
            };
            var createGeofenceEvent3 = new CreateGeofenceEvent
            {
                CustomerUID  = custUid,
                UserUID      = userId,
                GeofenceUID  = Guid.NewGuid(),
                GeofenceName = "Boundary three",
                GeofenceType = geofenceType,
                GeometryWKT  = "POLYGON((82.257874 14.677856,81.856873 15.039345,82.375977 15.443052,82.257874 14.677856))",
                ActionUTC    = firstCreatedUtc
            };
            var deleteGeofenceEvent = new DeleteGeofenceEvent
            {
                GeofenceUID = createGeofenceEvent1.GeofenceUID,
                UserUID     = userId,
                ActionUTC   = firstCreatedUtc
            };

            this.GeofenceRepo.StoreEvent(createGeofenceEvent1).Wait();
            this.GeofenceRepo.StoreEvent(createGeofenceEvent2).Wait();
            this.GeofenceRepo.StoreEvent(createGeofenceEvent3).Wait();
            this.GeofenceRepo.StoreEvent(deleteGeofenceEvent).Wait();

            var ids = new List <string>
            {
                createGeofenceEvent1.GeofenceUID.ToString(),
                createGeofenceEvent2.GeofenceUID.ToString(),
                createGeofenceEvent3.GeofenceUID.ToString()
            };
            var g = this.GeofenceRepo.GetGeofences(ids);

            g.Wait();
            Assert.IsNotNull(g.Result, "Unable to retrieve geofences from geofenceRepo");
            Assert.AreEqual(2, g.Result.Count(), "Wrong number of geofences retrieved");
        }