public async void TestTailsLogsAfterUpdate() { var mockConsole = GetMockConsole(); var mockWebDavClient = GetMockClient(); var log = new Logger <TailCommand>(new NullLoggerFactory()); var tailCommand = new TailCommand(log, mockConsole.Object, mockWebDavClient.Object); var result = tailCommand.RunCommand(new CancellationToken(), new List <string>(), interval: 300); // after the delay an update round should have occurred await Task.Delay(400); mockWebDavClient.Verify(x => x.UpdateFile(It.IsAny <WebDAVFile>(), true), Times.Exactly(2)); mockConsole.Verify(x => x.WriteLine(It.Is <string>(s => s.Contains("config is not defined"))), Times.Once); mockConsole.Verify(x => x.WriteLine(It.Is <string>(s => s.Contains("Error 2"))), Times.Once); mockConsole.Verify(x => x.WriteLine(It.Is <string>(s => s.Contains("Error 3"))), Times.Once); }
public async void TestEnumeratesLogsAndOutputsLastLine() { var mockConsole = GetMockConsole(); var mockWebDavClient = GetMockClient(); var log = new Logger <TailCommand>(new NullLoggerFactory()); mockConsole.Setup(x => x.WriteLine(It.IsAny <string>())).Verifiable(); var tailCommand = new TailCommand(log, mockConsole.Object, mockWebDavClient.Object); var result = tailCommand.RunCommand(new CancellationToken(), new List <string>()); // TODO refactor to send cancellation after verifying await Task.Delay(100); mockWebDavClient.Verify(x => x.ListDirectory(WebDAVLocation.Logs, ""), Times.Once); mockWebDavClient.Verify(x => x.UpdateFile(It.IsAny <WebDAVFile>(), true), Times.Once); // The first log should never be output as it is never the latest mockConsole.Verify(x => x.WriteLine(It.Is <string>(s => s.Contains("Error 1"))), Times.Never); mockConsole.Verify(x => x.WriteLine(It.Is <string>(s => s.Contains("config is not defined"))), Times.Once); }