public void UpdateZipFilesTestShouldNotCreateBatches() { _packageBuilder.Setup(x => x.BuildPackageContentV2(It.IsAny <DateTime>(), It.IsAny <string>())).Returns(new List <byte[]>()); _zipFileService = new ZipFileService(_configuration, _packageBuilder.Object, _zipFileInfoService.Object, _fileSystem.Object); _zipFileService.UpdateZipFiles(DateTime.Now.AddDays(-1), DateTime.Now); _fileSystem.Verify(x => x.WriteAllBytes(It.IsAny <string>(), It.IsAny <byte[]>()), Times.Never()); }
public void UpdateZipFilesTestShouldCreateTwoBatches(string value) { if (value == "dk") { _packageBuilder.Setup(x => x.BuildPackageContentV2(It.IsAny <DateTime>(), ZipFileOrigin.Dk)).Returns(new List <byte[]>()); } if (value == "all") { _packageBuilder.Setup(x => x.BuildPackageContentV2(It.IsAny <DateTime>(), ZipFileOrigin.All)).Returns(new List <byte[]>()); } _zipFileService = new ZipFileService(_configuration, _packageBuilder.Object, _zipFileInfoService.Object, _fileSystem.Object); _zipFileService.UpdateZipFiles(DateTime.Now.AddDays(-1), DateTime.Now); _fileSystem.Verify(x => x.WriteAllBytes(It.IsAny <string>(), It.IsAny <byte[]>()), Times.Exactly(2)); }
public void GenerateZipFiles() { try { var currentDate = _dateTimeNowWrapper.UtcNow; DateTime lastCreationDate = GetLastCreationDateFromSettings(currentDate); _zipFileService.UpdateZipFiles(lastCreationDate, currentDate); _settingRepository.SetSetting(lastCreatedDateSettingKey, currentDate.ToString()); _logger.LogInformation("Updated zip files"); } catch (Exception e) { string inner = (e.InnerException != null) ? (e.InnerException.Message + " : ") : String.Empty; _logger.LogError($"Updating of zip files failed. {inner}{e.Message}"); } }
public void UpdateZipFilesTestShouldCreateFourBatches() { _zipFileService = new ZipFileService(_configuration, _packageBuilder.Object, _zipFileInfoService.Object, _fileSystem.Object); _zipFileService.UpdateZipFiles(DateTime.Now.AddDays(-1), DateTime.Now); _fileSystem.Verify(x => x.WriteAllBytes(It.IsAny <string>(), It.IsAny <byte[]>()), Times.Exactly(4)); }
public void UpdateZipFilesTestShouldCreateNewDirectories() { _zipFileService = new ZipFileService(_configuration, _packageBuilder.Object, _zipFileInfoService.Object, _fileSystem.Object); _zipFileService.UpdateZipFiles(DateTime.Now.AddDays(-1), DateTime.Now); _fileSystem.Verify(x => x.CreateDirectory(It.IsAny <string>()), Times.Exactly(3)); }