예제 #1
0
        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);
            });
        }
예제 #2
0
 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);
        }
예제 #4
0
 public static void SetTestContextDataByMockCallbacksForCLI(CLITestContext testContext)
 {
     MockObjectsProvider.SetProcessResultsToTestContextForCLI(testContext);
     MockObjectsProvider.SetConsoleOutputToTestContext(testContext);
 }