private static void SetConsoleOutputToTestContext(CLITestContext testContext) { MockConsole .Setup(m => m.Out.Write(It.IsAny <string>())) .Callback <string>((str) => { testContext.AppendToConsoleOut(str); }); MockConsole .Setup(m => m.SetCursorPosition(It.IsAny <int>(), It.IsAny <int>())) .Callback <int, int>((left, top) => { testContext.ClearCurrentMessage(left); }); MockConsole .Setup(m => m.Error.Write(It.IsAny <string>())) .Callback <string>((str) => { testContext.AppendToConsoleError(str); }); }
private static void SetProcessResultsToTestContextForCLI(CLITestContext testContext) { MockConsoleProcessMessages .Setup(m => m.ProcessCompleteForMockSniffer(It.IsAny <ProcessResults>())) .Callback <ProcessResults>((processResults) => { testContext.ProcessResults = processResults; }); }
public void Files_ID_IsRequired() { //Arrange CLITestContext testContext = new CLITestContext(new ProcessTestContext(new TestArgs())); MockObjectsProvider.SetTestContextDataByMockCallbacksForCLI(testContext); CLIRunner.CLIRun($"files"); AssertTextByLines assertConsoleOutTextByLines = new AssertTextByLines(GetType().Name, "ConsoleError", testContext.ConsoleError, 1); assertConsoleOutTextByLines.AssertLineMessage("Option '--id' is required.", true); }
public static void SetTestContextDataByMockCallbacksForCLI(CLITestContext testContext) { MockObjectsProvider.SetProcessResultsToTestContextForCLI(testContext); MockObjectsProvider.SetConsoleOutputToTestContext(testContext); }