public void CreateWorkOrder_returns_workOrder() { // //Arrange _repo = new Mock <IWorkOrderRepository>(); _uow = new Mock <IUnitOfWork>(); _lRepo = new Mock <ILookupRepository>(); _cfg = new Mock <IConfigService>(); _tpServ = new Mock <ITransportProvidersService>(); var _wo = (WorkOrder)Records.order.Clone(); var _l = (Lookup)Records.lookup.Clone(); var _tp = (TransportProvider)Records.transportProvider.Clone(); string user = "******"; _wo.datecreated = DateTime.MinValue; _wo.dateupdated = DateTime.MinValue; _repo.Setup(r => r.Add(_wo)).Returns(_wo); _lRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(_l); _tpServ.Setup(r => r.Get(It.IsAny <int>())).Returns(_tp); _waServ = new Mock <IWorkAssignmentService>(); var _serv = new WorkOrderService(_repo.Object, _waServ.Object, _tpServ.Object, _lRepo.Object, _uow.Object, _map.Object, _cfg.Object); // //Act var result = _serv.Create(_wo, user); // //Assert Assert.IsInstanceOfType(result, typeof(WorkOrder)); Assert.IsTrue(result.createdby == user); Assert.IsTrue(result.updatedby == user); Assert.IsTrue(result.datecreated > DateTime.MinValue); Assert.IsTrue(result.dateupdated > DateTime.MinValue); }
public FluentRecordBase AddWorkOrder( DateTime?datecreated = null, DateTime?dateupdated = null, DateTime?dateTimeOfWork = null, int?paperordernum = null, int?status = null ) { // // DEPENDENCIES if (_lcache == null) { AddLookupCache(); } if (_emp == null) { AddEmployer(); } if (_servWO == null) { AddServWorkOrder(); } // // ARRANGE _wo = (WorkOrder)Records.order.Clone(); _wo.Employer = _emp; _wo.workAssignments = new List <WorkAssignment>(); if (datecreated != null) { _wo.datecreated = (DateTime)datecreated; } if (dateupdated != null) { _wo.dateupdated = (DateTime)dateupdated; } if (paperordernum != null) { _wo.paperOrderNum = paperordernum; } if (dateTimeOfWork != null) { _wo.dateTimeofWork = (DateTime)dateTimeOfWork; } if (status != null) { _wo.statusID = (int)status; } // // ACT _servWO.Create(_wo, _user); return(this); }
public async void Create() { var mock = new ServiceMockFacade <IWorkOrderRepository>(); var model = new ApiWorkOrderRequestModel(); mock.RepositoryMock.Setup(x => x.Create(It.IsAny <WorkOrder>())).Returns(Task.FromResult(new WorkOrder())); var service = new WorkOrderService(mock.LoggerMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.WorkOrderModelValidatorMock.Object, mock.BOLMapperMockFactory.BOLWorkOrderMapperMock, mock.DALMapperMockFactory.DALWorkOrderMapperMock, mock.BOLMapperMockFactory.BOLWorkOrderRoutingMapperMock, mock.DALMapperMockFactory.DALWorkOrderRoutingMapperMock); CreateResponse <ApiWorkOrderResponseModel> response = await service.Create(model); response.Should().NotBeNull(); mock.ModelValidatorMockFactory.WorkOrderModelValidatorMock.Verify(x => x.ValidateCreateAsync(It.IsAny <ApiWorkOrderRequestModel>())); mock.RepositoryMock.Verify(x => x.Create(It.IsAny <WorkOrder>())); }
public void CreateWorkOrder_returns_workOrder() { // //Arrange _repo = new Mock<IWorkOrderRepository>(); _uow = new Mock<IUnitOfWork>(); var _wo = (WorkOrder)Records.order.Clone(); string user = "******"; _wo.datecreated = DateTime.MinValue; _wo.dateupdated = DateTime.MinValue; _repo.Setup(r => r.Add(_wo)).Returns(_wo); _waServ = new Mock<IWorkAssignmentService>(); var _serv = new WorkOrderService(_repo.Object, _waServ.Object, _uow.Object); // //Act var result = _serv.Create(_wo, user); // //Assert Assert.IsInstanceOfType(result, typeof(WorkOrder)); Assert.IsTrue(result.Createdby == user); Assert.IsTrue(result.Updatedby == user); Assert.IsTrue(result.datecreated > DateTime.MinValue); Assert.IsTrue(result.dateupdated > DateTime.MinValue); }