public async Task ArchiveLogFiles_IOException_ReturnFalse(string startTime, string endTime, ErrorMessage error) { // Arrange mockArchiveService.Setup(x => x.ArchiveLogFiles(new List <string>())).Throws(new IOException()); IArchiveManager archiveManager = new ArchiveManager(mockArchiveService.Object, mockFolderHandlerService.Object); // Act var archiveResult = await archiveManager.ArchiveLogFiles(DateTimeOffset.Parse(startTime), DateTimeOffset.Parse(endTime)); // Assert Assert.IsFalse(archiveResult.WasSuccessful); Assert.IsTrue(archiveResult.ErrorMessage == error); }
public async Task ArchiveLogFiles_ArchiveFailure_ReturnFalse(string startTime, string endTime) { // Arrange mockArchiveService.Setup(x => x.ArchiveLogFiles(new List <string>())).Returns(Task.FromResult(false)); IArchiveManager archiveManager = new ArchiveManager(mockArchiveService.Object, mockFolderHandlerService.Object); // Act var archiveResult = await archiveManager.ArchiveLogFiles(DateTimeOffset.Parse(startTime), DateTimeOffset.Parse(endTime)); // Assert Assert.IsFalse(archiveResult.WasSuccessful); }
public async Task ArchiveLogFiles_NoValidLogs_ReturnFalse(string startTime, string endTime, string message, LogLevel logLevel, LogTarget logTarget) { // Arrange logService.Log(message, logTarget, logLevel, this.ToString(), "Test_Logs"); logService.Log(message, logTarget, logLevel, this.ToString(), "User_Logging"); IArchiveManager archiveManager = new ArchiveManager(archiveService, folderHandlerService); // Act var result = await archiveManager.ArchiveLogFiles(DateTimeOffset.Parse(startTime), DateTimeOffset.Parse(endTime)); // Assert Assert.IsFalse(result.WasSuccessful); }
public async Task ArchiveLogFiles_LogsArchived_ReturnTrue(string message, LogLevel logLevel, LogTarget logTarget) { // Arrange logService.Log(message, logTarget, logLevel, this.ToString(), "Test_Logs"); logService.Log(message, logTarget, logLevel, this.ToString(), "User_Logging"); var startTime = DateTimeOffset.UtcNow.AddDays(-1); var endTime = DateTimeOffset.UtcNow.AddDays(1); IArchiveManager archiveManager = new ArchiveManager(archiveService, folderHandlerService); // Act var result = await archiveManager.ArchiveLogFiles(startTime, endTime); // Assert Assert.IsTrue(result.WasSuccessful); }