public void GivenValidData_WhenITryToUpdateTheGridRunAndTheGridRunIsNotFound_IGetAUnityException() { GridRun gridRun = null; _gridRunRepository.Setup(g => g.GetGridRun(It.IsAny <int>())).Returns(gridRun); Action act = () => _gridRunService.Update(It.IsAny <int>(), It.IsAny <DateTime?>(), It.IsAny <DateTime?>(), It.IsAny <int>(), It.IsAny <int>()); act.ShouldThrow <UnityException>(); }
public void ProcessHouseHoldingRun() { HouseHoldingRunData houseHoldingRunData = _houseHoldingFileRepository.GetHouseHoldingData(); var houseHoldingRun = new HouseHoldingRun { Grid = houseHoldingRunData.Grid, StartDate = houseHoldingRunData.StartDate, EndDate = houseHoldingRunData.EndDate }; _houseHoldingRunRepository.Create(houseHoldingRun); foreach (var grid in houseHoldingRunData.ProcessingGridRun) { var gridRun = _gridRunService.GetGridRun(grid); _gridRunService.Update(gridRun.Id, gridRun.StartDate, gridRun.EndDate, gridRun.Status, gridRun.XmlFileId, houseHoldingRun.Id); } foreach (var documentData in houseHoldingRunData.DocumentRunData) { var document = _documentService.GetDocument(documentData.DocumentId); var houseHold = new HouseHold() { HouseHoldDate = DateTime.Now, DocumentId = document.Id }; _houseHoldRepository.Create(houseHold); _documentService.Update(document.Id, houseHoldingRun.Id); } }
public void ProcessGridRun(string fileName, string applicationCode, string applicationDesc, string grid, DateTime?startDate, DateTime?endDate, GridRunStatus gridRunStatus, bool?isDebug) { XmlFile xmlFile = _xmlFileService.GetFile(fileName); if (xmlFile == null) { _logger.Warn(string.Format("Unable to update file information as the file is not in the database. File name is {0}.", fileName)); } GridRun gridRun = SearchForGridRunThatCameFromOneStep(fileName, applicationCode, grid, startDate) ?? SearchForGridThatCameFromNTGEN95Import(applicationCode, grid); if (gridRun != null && xmlFile == null) { _gridRunService.Update(gridRun.Id, startDate, endDate, (int)gridRunStatus); } else if (gridRun != null) { _gridRunService.Update(gridRun.Id, startDate, endDate, (int)gridRunStatus, xmlFile.Id); } else { Application application = _applicationService.GetApplication(applicationCode); if (application == null) { application = _applicationService.CreateApplication(applicationCode, applicationDesc); } _gridRunService.Create( application.Id, xmlFile != null ? xmlFile.Id : (int?)null, (int)gridRunStatus, grid, isDebug.GetValueOrDefault(), startDate == null ? (DateTime?)null : startDate.Value, endDate == null ? (DateTime?)null : endDate.Value); } }