Esempio n. 1
0
        public async Task GetBoundaryExecutor()
        {
            string custUid     = Guid.NewGuid().ToString();
            string userUid     = Guid.NewGuid().ToString();
            string projectUid  = Guid.NewGuid().ToString();
            string boundaryUid = Guid.NewGuid().ToString();
            string name        = "blah";
            string geometryWKT = "whatever";

            var configStore = serviceProvider.GetRequiredService <IConfigurationStore>();
            var logger      = serviceProvider.GetRequiredService <ILoggerFactory>();

            var geofenceRepo = new Mock <GeofenceRepository>(configStore, logger);
            var geofence     = new Geofence
            {
                CustomerUID     = custUid,
                UserUID         = userUid,
                GeofenceUID     = boundaryUid,
                Name            = name,
                GeometryWKT     = geometryWKT,
                GeofenceType    = GeofenceType.Filter,
                LastActionedUTC = DateTime.UtcNow
            };

            geofenceRepo.As <IGeofenceRepository>().Setup(g => g.GetGeofence(It.IsAny <string>())).ReturnsAsync(geofence);

            var projectRepo     = new Mock <ProjectRepository>(configStore, logger);
            var projectGeofence = new ProjectGeofence {
                GeofenceUID = boundaryUid, ProjectUID = projectUid
            };

            projectRepo.As <IProjectRepository>().Setup(p => p.GetAssociatedGeofences(It.IsAny <string>())).ReturnsAsync(new List <ProjectGeofence> {
                projectGeofence
            });

            var geofenceToTest = new GeofenceDataSingleResult(AutoMapperUtility.Automapper.Map <GeofenceData>(geofence));

            var request = BoundaryUidRequestFull.Create
                          (
                custUid,
                false,
                new ProjectData {
                ProjectUID = projectUid
            },
                userUid,
                boundaryUid
                          );

            var executor =
                RequestExecutorContainer.Build <GetBoundaryExecutor>(configStore, logger, serviceExceptionHandler,
                                                                     geofenceRepo.Object, projectRepo.Object);
            var result = await executor.ProcessAsync(request) as GeofenceDataSingleResult;

            Assert.NotNull(result);
            Assert.Equal(geofenceToTest.GeofenceData.GeofenceUID, result.GeofenceData.GeofenceUID);
            Assert.Equal(geofenceToTest.GeofenceData.GeofenceName, result.GeofenceData.GeofenceName);
            Assert.Equal(geofenceToTest.GeofenceData.GeometryWKT, result.GeofenceData.GeometryWKT);
        }
Esempio n. 2
0
        private BoundaryUidRequestFull CreateAndValidateRequest(Guid custUid, Guid projectUid, Guid userId, Guid boundaryUid)
        {
            var request = BoundaryUidRequestFull.Create(
                custUid.ToString(),
                false,
                new ProjectData()
            {
                ProjectUID = projectUid.ToString()
            },
                userId.ToString(),
                boundaryUid.ToString());

            request.Validate(ServiceExceptionHandler);
            return(request);
        }
Esempio n. 3
0
        public void MapBoundaryRequestToDeleteFilterEvent()
        {
            var request = BoundaryUidRequestFull.Create
                          (
                Guid.NewGuid().ToString(),
                false,
                new ProjectData {
                ProjectUID = Guid.NewGuid().ToString()
            },
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString()
                          );

            var result = AutoMapperUtility.Automapper.Map <DeleteGeofenceEvent>(request);

            Assert.Equal(request.UserUid, result.UserUID.ToString());
            Assert.Equal(request.BoundaryUid, result.GeofenceUID.ToString());
        }
Esempio n. 4
0
        public async Task <ContractExecutionResult> DeleteBoundary(string projectUid, [FromQuery] string boundaryUid)
        {
            Log.LogInformation(
                $"{ToString()}.DeleteBoundary: CustomerUID={CustomerUid} ProjectUid: {projectUid} BoundaryUid: {boundaryUid}");

            var requestFull = BoundaryUidRequestFull.Create(
                CustomerUid,
                IsApplication,
                await GetProject(projectUid),
                GetUserId,
                boundaryUid);

            requestFull.Validate(ServiceExceptionHandler);

            var executor = RequestExecutorContainer.Build <DeleteBoundaryExecutor>(ConfigStore, Logger,
                                                                                   ServiceExceptionHandler, _geofenceRepository, _projectRepository, ProjectProxy);

            var result = await executor.ProcessAsync(requestFull);

            Log.LogInformation(
                $"{ToString()}.DeleteBoundary Completed: resultCode: {result?.Code} result: {JsonConvert.SerializeObject(result)}");
            return(result);
        }
Esempio n. 5
0
        public async Task DeleteBoundaryExecutor()
        {
            string custUid     = Guid.NewGuid().ToString();
            string userUid     = Guid.NewGuid().ToString();
            string projectUid  = Guid.NewGuid().ToString();
            string boundaryUid = Guid.NewGuid().ToString();
            string name        = "not entry";
            string geometryWKT = "whatever";

            var configStore = serviceProvider.GetRequiredService <IConfigurationStore>();
            var logger      = serviceProvider.GetRequiredService <ILoggerFactory>();

            var geofenceRepo = new Mock <GeofenceRepository>(configStore, logger);
            var geofence     = new Geofence
            {
                CustomerUID     = custUid,
                UserUID         = userUid,
                GeofenceUID     = boundaryUid,
                Name            = name,
                GeometryWKT     = geometryWKT,
                GeofenceType    = GeofenceType.Filter,
                LastActionedUTC = DateTime.UtcNow
            };

            geofenceRepo.As <IGeofenceRepository>().Setup(g => g.GetGeofence(It.IsAny <string>())).ReturnsAsync(geofence);
            geofenceRepo.As <IGeofenceRepository>().Setup(g => g.StoreEvent(It.IsAny <DeleteGeofenceEvent>())).ReturnsAsync(1);

            var projectRepo     = new Mock <ProjectRepository>(configStore, logger);
            var projectGeofence = new ProjectGeofence {
                GeofenceUID = boundaryUid, ProjectUID = projectUid
            };

            projectRepo.As <IProjectRepository>().Setup(p => p.GetAssociatedGeofences(It.IsAny <string>())).ReturnsAsync(new List <ProjectGeofence> {
                projectGeofence
            });

            var productivity3dV2ProxyNotification = new Mock <IProductivity3dV2ProxyNotification>();

            productivity3dV2ProxyNotification.Setup(ps => ps.NotifyFilterChange(It.IsAny <Guid>(), It.IsAny <Guid>(), null)).ReturnsAsync(new BaseMasterDataResult());

            var request = BoundaryUidRequestFull.Create
                          (
                custUid,
                false,
                new ProjectData {
                ProjectUID = projectUid
            },
                userUid,
                boundaryUid
                          );

            var executor =
                RequestExecutorContainer.Build <DeleteBoundaryExecutor>(configStore, logger, serviceExceptionHandler,
                                                                        geofenceRepo.Object, projectRepo.Object,
                                                                        productivity3dV2ProxyNotification: productivity3dV2ProxyNotification.Object);
            var result = await executor.ProcessAsync(request);

            Assert.NotNull(result);
            Assert.Equal(0, result.Code);
            Assert.Equal("success", result.Message);
        }