public void GivenAFileName_WhenAXmlFileIsRequested_AndTheDataBaseIsUnavailable_ThenAUnityExceptionIsThrown() { _xmlFileRepository.Setup(a => a.GetFile(It.IsAny <string>())).Throws <Exception>(); Action act = () => _xmlFileService.GetFile(It.IsAny <string>()); act.ShouldThrow <UnityException>(); }
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); } }