Example #1
0
        public static Task <ITastyRemote> AttachToStream(TastyScope scope, Stream remoteStream)
        {
            _ = scope ?? throw new ArgumentNullException(nameof(scope));
            _ = remoteStream ?? throw new ArgumentNullException(nameof(remoteStream));

            var remote = JsonRpc.Attach <ITastyRemote>(remoteStream);

            return(Task.FromResult(remote));
        }
Example #2
0
 static (TastyScope scope, TestGroup group)CreateScope(string description = testDescription)
 {
     var scope = new TastyScope
     {
         ClearBeforeRun       = false,
         IsInteractiveRunHook = () => Task.FromResult(false)
     };
     var group = scope.Describe(description, () => { });
     return(scope, group);
 }
Example #3
0
 static (TastyScope scope, TestCase test, Action action)CreateCase(string name = testCaseName)
 {
     var scope = new TastyScope
     {
         ClearBeforeRun       = false,
         IsInteractiveRunHook = () => Task.FromResult(false)
     };
     var executor = new TestExecutor(scope);
     var action   = A.Fake <Action>();
     var testCase = scope.It(name, action);
     return(scope, testCase, action);
 }
Example #4
0
 public TestGroupContext(
     TestGroup currentGroup,
     TastyScope currentScope,
     Queue <TestGroup> groupQueue,
     Queue <TestCase> testQueue
     )
 {
     CurrentGroup = currentGroup ?? throw new ArgumentNullException(nameof(currentGroup));
     CurrentScope = currentScope ?? throw new ArgumentNullException(nameof(currentScope));
     GroupQueue   = groupQueue ?? throw new ArgumentNullException(nameof(groupQueue));
     TestQueue    = testQueue ?? throw new ArgumentNullException(nameof(testQueue));
 }
Example #5
0
        public static void Commander() => Describe(nameof(TastyCommander), () =>
        {
            (Uri connectionString, TastyScope scope, TastyCommander commander, AsyncTestReporter reporter)CreateRemote()
            {
                var connectionString = InMemoryConnectionStringBuilder.CreateNewConnection();

                var scope = new TastyScope()
                {
                    LoadPlugins    = false,
                    ClearBeforeRun = false,
                    //This would block the interactive run
                    IsInteractiveRunHook = () => Task.FromResult(false)
                }
                .UseInMemoryTransport()
                .UseRemoteReporter();

                scope.It("A test case", () => true);
                scope.ParseConnectionString = () => TastyRemoteDefaults.ParseConnectionString(connectionString.ToString());

                var commander = new TastyCommander()
                {
                    LoadPlugins = false
                }
                .UseInMemoryTransport();

                var reporter = A.Fake <AsyncTestReporter>();
                commander.RegisterReporter(reporter);

                return(connectionString, scope, commander, reporter);
            }

            It("Remote scope will be executed", async() =>
            {
                var(connectionString, scope, commander, reporter) = CreateRemote();
                var remote = commander.ConnectToRemote(connectionString);

                var runner = scope.Run();

                await Task.WhenAll(remote, runner);

                A.CallTo(reporter).MustHaveHappened();
            });

            It("Remote scope succeeds with non zero exit code", async() =>
            {
Example #6
0
        public TestExecutor(TastyScope scope)
        {
            Scope = scope ?? throw new ArgumentNullException(nameof(scope));

            this
            .UseRemoteDisposal()
            .UseEndTestPipeline()
            .UseTestPipelineCompleted()
            .UseResetConsoleColor()
            .UseExitCodeReporter()
            .UseSummaryReporters()
            .UseInteractiveRunDetection()
            .UseParseConnectionString()
            .UseRemote()
            .UseRegisterCommands()
            .UseSelectCommand()
            .UseClearConsole()
            .UseRemoteClearConsole()
            .UseResetRemoteConsoleColor()
            .UseRunCommands()
            ;

            this
            .UseTestGroupReporters()
            .UseTestGroupStopwatch()
            .UseTestGroupScope()
            .UseTestGroupExecutor()
            .UseTestGroupCollector()
            .UseTestGroupForceVisitor()
            .UseTestCaseCollector()
            ;

            this
            .UseTestReporters()
            .UseTestStopwatch()
            .UseForcedTestExecutor()
            .UseIgnoreTestExecutor()
            .UseBeforeEachTest()
            .UseTestExecutor()
            .UseAfterEachTest()
            ;
        }
Example #7
0
        public static TastyScope RegisterRemoteReporter(this TastyScope scope)
        {
            _ = scope ?? throw new ArgumentNullException(nameof(scope));

            var hook = scope.ConnectToRemoteRunHook;

            scope.ConnectToRemoteRunHook = async(scope, remoteStream) =>
            {
                var remote = await hook(scope, remoteStream).ConfigureAwait(false);

                Task TestReporter(TestCaseResult testCase)
                => remote.Report(testCase);

                Task SummaryReporter(IEnumerable <TestCaseResult> testCases)
                => remote.Report(testCases);

                scope.RegisterReporter(TestReporter);
                scope.RegisterReporter(SummaryReporter);

                return(remote);
            };

            return(scope);
        }
Example #8
0
 public static TastyScope UseConsoleReporter(this TastyScope scope)
 => scope.RegisterConsoleReporter();
 public static TastyScope UseNamedPipesTransport(this TastyScope scope)
 => (scope ?? throw new ArgumentNullException(nameof(scope)))
Example #10
0
 public static TastyScope Use(TastyScope scope)
 {
     UseScopeWasCalled = true;
     return(scope);
 }
Example #11
0
 public static TastyScope RegisterNyanReporter(this TastyScope scope)
 => (scope ?? throw new ArgumentNullException(nameof(scope))).RegisterReporter(Report)
Example #12
0
 public TestExecutionContext(TestCase currentCase, TastyScope currentScope, TestGroup?currentGroup)
 {
     CurrentCase  = currentCase ?? throw new ArgumentNullException(nameof(currentCase));
     CurrentScope = currentScope ?? throw new ArgumentNullException(nameof(currentScope));
     CurrentGroup = currentGroup;
 }
Example #13
0
 public static TastyScope UseRemoteReporter(this TastyScope scope)
 => scope.RegisterRemoteReporter();
Example #14
0
 public static TastyScope UseNyanReporter(this TastyScope scope)
 => scope.RegisterNyanReporter();