public virtual ApiWorkOrderRoutingResponseModel MapBOToModel(
            BOWorkOrderRouting boWorkOrderRouting)
        {
            var model = new ApiWorkOrderRoutingResponseModel();

            model.SetProperties(boWorkOrderRouting.WorkOrderID, boWorkOrderRouting.ActualCost, boWorkOrderRouting.ActualEndDate, boWorkOrderRouting.ActualResourceHr, boWorkOrderRouting.ActualStartDate, boWorkOrderRouting.LocationID, boWorkOrderRouting.ModifiedDate, boWorkOrderRouting.OperationSequence, boWorkOrderRouting.PlannedCost, boWorkOrderRouting.ProductID, boWorkOrderRouting.ScheduledEndDate, boWorkOrderRouting.ScheduledStartDate);

            return(model);
        }
示例#2
0
        public async void TestGet()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());
            ApiWorkOrderRoutingResponseModel response = await client.WorkOrderRoutingGetAsync(1);

            response.Should().NotBeNull();
        }
示例#3
0
        public async virtual Task <IActionResult> Get(int id)
        {
            ApiWorkOrderRoutingResponseModel response = await this.WorkOrderRoutingService.Get(id);

            if (response == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                return(this.Ok(response));
            }
        }
示例#4
0
        public async void Get_null_record()
        {
            var mock = new ServiceMockFacade <IWorkOrderRoutingRepository>();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <WorkOrderRouting>(null));
            var service = new WorkOrderRoutingService(mock.LoggerMock.Object,
                                                      mock.RepositoryMock.Object,
                                                      mock.ModelValidatorMockFactory.WorkOrderRoutingModelValidatorMock.Object,
                                                      mock.BOLMapperMockFactory.BOLWorkOrderRoutingMapperMock,
                                                      mock.DALMapperMockFactory.DALWorkOrderRoutingMapperMock);

            ApiWorkOrderRoutingResponseModel response = await service.Get(default(int));

            response.Should().BeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <int>()));
        }
示例#5
0
        public async void TestUpdate()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);

            var client = new ApiClient(testServer.CreateClient());

            ApiWorkOrderRoutingResponseModel model = await client.WorkOrderRoutingGetAsync(1);

            ApiWorkOrderRoutingModelMapper mapper = new ApiWorkOrderRoutingModelMapper();

            UpdateResponse <ApiWorkOrderRoutingResponseModel> updateResponse = await client.WorkOrderRoutingUpdateAsync(model.WorkOrderID, mapper.MapResponseToRequest(model));

            updateResponse.Record.Should().NotBeNull();
            updateResponse.Success.Should().BeTrue();
        }
        public void MapResponseToRequest()
        {
            var mapper = new ApiWorkOrderRoutingModelMapper();
            var model  = new ApiWorkOrderRoutingResponseModel();

            model.SetProperties(1, 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"));
            ApiWorkOrderRoutingRequestModel response = mapper.MapResponseToRequest(model);

            response.ActualCost.Should().Be(1m);
            response.ActualEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ActualResourceHr.Should().Be(1);
            response.ActualStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LocationID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.OperationSequence.Should().Be(1);
            response.PlannedCost.Should().Be(1m);
            response.ProductID.Should().Be(1);
            response.ScheduledEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ScheduledStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
        }
示例#7
0
        public async void Create_Errors()
        {
            WorkOrderRoutingControllerMockFacade mock = new WorkOrderRoutingControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiWorkOrderRoutingResponseModel> >(new FluentValidation.Results.ValidationResult());
            var mockRecord   = new ApiWorkOrderRoutingResponseModel();

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiWorkOrderRoutingRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiWorkOrderRoutingResponseModel> >(mockResponse.Object));
            WorkOrderRoutingController controller = new WorkOrderRoutingController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Create(new ApiWorkOrderRoutingRequestModel());

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiWorkOrderRoutingRequestModel>()));
        }
示例#8
0
        public void MapBOToModel()
        {
            var mapper            = new BOLWorkOrderRoutingMapper();
            BOWorkOrderRouting bo = new BOWorkOrderRouting();

            bo.SetProperties(1, 1m, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1m, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"));
            ApiWorkOrderRoutingResponseModel response = mapper.MapBOToModel(bo);

            response.ActualCost.Should().Be(1m);
            response.ActualEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ActualResourceHr.Should().Be(1);
            response.ActualStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.LocationID.Should().Be(1);
            response.ModifiedDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.OperationSequence.Should().Be(1);
            response.PlannedCost.Should().Be(1m);
            response.ProductID.Should().Be(1);
            response.ScheduledEndDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ScheduledStartDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.WorkOrderID.Should().Be(1);
        }
示例#9
0
        public async void All_Exists()
        {
            WorkOrderRoutingControllerMockFacade mock = new WorkOrderRoutingControllerMockFacade();
            var record  = new ApiWorkOrderRoutingResponseModel();
            var records = new List <ApiWorkOrderRoutingResponseModel>();

            records.Add(record);
            mock.ServiceMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            WorkOrderRoutingController controller = new WorkOrderRoutingController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.All(1000, 0);

            response.Should().BeOfType <OkObjectResult>();
            (response as OkObjectResult).StatusCode.Should().Be((int)HttpStatusCode.OK);
            var items = (response as OkObjectResult).Value as List <ApiWorkOrderRoutingResponseModel>;

            items.Count.Should().Be(1);
            mock.ServiceMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
示例#10
0
        public virtual async Task <IActionResult> Patch(int id, [FromBody] JsonPatchDocument <ApiWorkOrderRoutingRequestModel> patch)
        {
            ApiWorkOrderRoutingResponseModel record = await this.WorkOrderRoutingService.Get(id);

            if (record == null)
            {
                return(this.StatusCode(StatusCodes.Status404NotFound));
            }
            else
            {
                ApiWorkOrderRoutingRequestModel model = await this.PatchModel(id, patch);

                UpdateResponse <ApiWorkOrderRoutingResponseModel> result = await this.WorkOrderRoutingService.Update(id, model);

                if (result.Success)
                {
                    return(this.Ok(result));
                }
                else
                {
                    return(this.StatusCode(StatusCodes.Status422UnprocessableEntity, result));
                }
            }
        }
示例#11
0
        public async void TestGet()
        {
            ApiWorkOrderRoutingResponseModel response = await this.Client.WorkOrderRoutingGetAsync(1);

            response.Should().NotBeNull();
        }