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)); }
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); }
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); }
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)); }
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() => {
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() ; }
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); }
public static TastyScope UseConsoleReporter(this TastyScope scope) => scope.RegisterConsoleReporter();
public static TastyScope UseNamedPipesTransport(this TastyScope scope) => (scope ?? throw new ArgumentNullException(nameof(scope)))
public static TastyScope Use(TastyScope scope) { UseScopeWasCalled = true; return(scope); }
public static TastyScope RegisterNyanReporter(this TastyScope scope) => (scope ?? throw new ArgumentNullException(nameof(scope))).RegisterReporter(Report)
public TestExecutionContext(TestCase currentCase, TastyScope currentScope, TestGroup?currentGroup) { CurrentCase = currentCase ?? throw new ArgumentNullException(nameof(currentCase)); CurrentScope = currentScope ?? throw new ArgumentNullException(nameof(currentScope)); CurrentGroup = currentGroup; }
public static TastyScope UseRemoteReporter(this TastyScope scope) => scope.RegisterRemoteReporter();
public static TastyScope UseNyanReporter(this TastyScope scope) => scope.RegisterNyanReporter();