public void CanCreateContextInstance() { var context = new TestContext(); context.Set("test", "test"); context.ShouldNotBeNull(); context.Get <string>("test").ShouldBe("test"); context.Get <int>("doesnotexist").ShouldBe(0); }
public async Task Can_execute_conveyor_belt() { CancellationTokenSource cts = new CancellationTokenSource(); var context = new TestContext(); var conveyor = new TestConveyor(context, cts.Token); await conveyor.Register(new TestCommand(runResult : "A")); await conveyor.Register(new TestCommand(runResult : "B")); await conveyor.Register(new TestCommand(runResult : "C")); await conveyor.Run(); context.Get <Guid>("Identifier").ShouldBe(context.Identifier); context.TestResult.ToString().ShouldBe("ABC"); }
public async Task Can_execute_conveyor_belt() { var cts = new CancellationTokenSource(); var logger = _loggerFactory.CreateLogger(typeof(TestConveyor)); var context = new TestContext(); var conveyor = new TestConveyor(context, logger, cts.Token); await conveyor.Register(new TestCommand(runResult : "A", logger : logger)); await conveyor.Register(new TestCommand(runResult : "B", logger : logger)); await conveyor.Register(new TestCommand(runResult : "C", logger : logger)); await conveyor.Run(); context.Get <Guid>("Identifier").ShouldBe(context.Identifier); context.TestResult.ToString().ShouldBe("ABC"); }
public void Missing_context_key_raises_exception() { var context = new TestContext(); Should.Throw <MissingExpectedContextDataException>(() => context.Get <string>("test", true)); }