protected void Ex04() { TestFixtures.RaiseException = true; var result = Fixture.Run(null, Substitute.For <IFixtureStepRunnerFactory>()); ExpectedFixtureDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute)); Expect($"the descriptor of the result should be as follows:{ExpectedFixtureDescriptor.ToDescription()}", () => result != null && FixtureDescriptorAssertion.Of(result.FixtureDescriptor) == ExpectedFixtureDescriptor); ExpectedFixtureResult = FixtureResultAssertion.ForNotNullException(true, true, true, 0, 0, FixtureStatus.Failed); Expect($"the result should be as follows:{ExpectedFixtureResult.ToDescription()}", () => result != null && FixtureResultAssertion.Of(result) == ExpectedFixtureResult); Expect("FixtureRunning event should be raised", () => FixtureRunningResult != null); ExpectedFixtureRunningDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute)); Expect($"the descriptor of the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningDescriptor.ToDescription()}", () => FixtureRunningResult != null && FixtureDescriptorAssertion.Of(FixtureRunningResult.FixtureDescriptor) == ExpectedFixtureRunningDescriptor); ExpectedFixtureRunningResult = FixtureResultAssertion.ForNullException(true, false, false, 0, 0, FixtureStatus.Running); Expect($"the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningResult.ToDescription()}", () => FixtureRunningResult != null && FixtureResultAssertion.Of(FixtureRunningResult) == ExpectedFixtureRunningResult); Expect("FixtureRun event should be raised", () => FixtureRunResult != null); Expect("the result on FixtureRun event should be the result that is returned by Run method", () => FixtureRunResult == result); Expect("FixtureStepRunning event should not be raised", () => FixtureStepRunningResult == null); Expect("FixtureStepRun event should not be raised", () => FixtureStepRunResult == null); }
protected void Ex02() { Filter.Accept(Arg.Any <FixtureDescriptor>()).Returns(true); var result = Fixture.Run(Filter, Substitute.For <IFixtureStepRunnerFactory>()); Expect("the fixture method should be called", () => TestFixtures.CalledFixtureMethods.Count == 1 && TestFixtures.CalledFixtureMethods.Contains(TargetFixtureType)); ExpectedFixtureDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute)); Expect($"the descriptor of the result should be as follows:{ExpectedFixtureDescriptor.ToDescription()}", () => result != null && FixtureDescriptorAssertion.Of(result.FixtureDescriptor) == ExpectedFixtureDescriptor); ExpectedFixtureResult = FixtureResultAssertion.ForNullException(true, true, true, 0, 0, FixtureStatus.Passed); Expect($"the result should be as follows:{ExpectedFixtureResult.ToDescription()}", () => result != null && FixtureResultAssertion.Of(result) == ExpectedFixtureResult); Expect("FixtureRunning event should be raised", () => FixtureRunningResult != null); ExpectedFixtureRunningDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute)); Expect($"the descriptor of the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningDescriptor.ToDescription()}", () => FixtureRunningResult != null && FixtureDescriptorAssertion.Of(FixtureRunningResult.FixtureDescriptor) == ExpectedFixtureRunningDescriptor); ExpectedFixtureRunningResult = FixtureResultAssertion.ForNullException(true, false, false, 0, 0, FixtureStatus.Running); Expect($"the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningResult.ToDescription()}", () => FixtureRunningResult != null && FixtureResultAssertion.Of(FixtureRunningResult) == ExpectedFixtureRunningResult); Expect("FixtureRun event should be raised", () => FixtureRunResult != null); Expect("the result on FixtureRun event should be the result that is returned by Run method", () => FixtureRunResult == result); Expect("FixtureStepRunning event should not be raised", () => FixtureStepRunningResult == null); Expect("FixtureStepRun event should not be raised", () => FixtureStepRunResult == null); }
void Ex01() { FixtureResult?result = default; Fixture.FixtureReady += (s, e) => result = e.Result; Fixture.Ready(); Expect("FixtureReady event should be raised", () => result != null); ExpectedFixtureDescriptor = FixtureDescriptorAssertion.Of("Fixture Method Example", "FixtureMethod", "Carna.TestFixtures+SimpleFixture.FixtureMethod", typeof(ExampleAttribute)); Expect($"the descriptor of the result should be as follows:{ExpectedFixtureDescriptor.ToDescription()}", () => result != null && FixtureDescriptorAssertion.Of(result.FixtureDescriptor) == ExpectedFixtureDescriptor); ExpectedFixtureResult = FixtureResultAssertion.ForNullException(false, false, false, 0, 0, FixtureStatus.Ready); Expect($"the result should be as follows:{ExpectedFixtureResult.ToDescription()}", () => result != null && FixtureResultAssertion.Of(result) == ExpectedFixtureResult); }
protected void Ex01() { var result = Fixture.Run(null, new TestFixtures.SimpleFixtureStepRunnerFactory()); Expect("the fixture method should be called", () => TestFixtures.CalledFixtureMethods.Count == 1 && TestFixtures.CalledFixtureMethods.Contains(TargetFixtureType)); ExpectedFixtureDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute)); Expect($"the descriptor of the result should be as follows:{ExpectedFixtureDescriptor.ToDescription()}", () => result != null && FixtureDescriptorAssertion.Of(result.FixtureDescriptor) == ExpectedFixtureDescriptor); ExpectedFixtureResult = FixtureResultAssertion.ForNullException(true, true, true, 1, 0, FixtureStatus.Passed); Expect($"the result should be as follows:{ExpectedFixtureResult.ToDescription()}", () => result != null && FixtureResultAssertion.Of(result) == ExpectedFixtureResult); if (result is null) { return; } var stepResult = result.StepResults.ElementAt(0); ExpectedFixtureStepResult = FixtureStepResultAssertion.Of("Description", null, FixtureStepStatus.Passed, typeof(ExpectStep)); Expect($"the the result of the step should be as follows:{ExpectedFixtureStepResult.ToDescription()}", () => FixtureStepResultAssertion.Of(stepResult) == ExpectedFixtureStepResult); Expect("FixtureRunning event should be raised", () => FixtureRunningResult != null); ExpectedFixtureRunningDescriptor = FixtureDescriptorAssertion.Of(TargetFixtureDescription, TargetMethodDescription, TargetMethodFullName, typeof(ExampleAttribute)); Expect($"the descriptor of the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningDescriptor.ToDescription()}", () => FixtureRunningResult != null && FixtureDescriptorAssertion.Of(FixtureRunningResult.FixtureDescriptor) == ExpectedFixtureRunningDescriptor); ExpectedFixtureRunningResult = FixtureResultAssertion.ForNullException(true, false, false, 0, 0, FixtureStatus.Running); Expect($"the result on FixtureRunning event should be as follows:{ExpectedFixtureRunningResult.ToDescription()}", () => FixtureRunningResult != null && FixtureResultAssertion.Of(FixtureRunningResult) == ExpectedFixtureRunningResult); Expect("FixtureRun event should be raised", () => FixtureRunResult != null); Expect("the result on FixtureRun event should be the result that is returned by Run method", () => FixtureRunResult == result); Expect("FixtureStepRunning event should be raised", () => FixtureStepRunningResult != null); ExpectedFixtureStepRunningResult = FixtureStepRunningResultAssertion.Of(stepResult.Step, true, false, false, null, FixtureStepStatus.Running); Expect($"the result of the step on FixtureRunning event should be as follows:{ExpectedFixtureStepRunningResult.ToDescription()}", () => FixtureStepRunningResult != null && FixtureStepRunningResultAssertion.Of(FixtureStepRunningResult) == ExpectedFixtureStepRunningResult); Expect("FixtureStepRun event should be raised", () => FixtureStepRunResult != null); Expect("the result on FixtureStepRun event should be the result that is returned by Run method", () => FixtureStepRunResult == stepResult); }
void Ex01() { var fixture = TestFixtures.CreateFixture <TestFixtures.SimpleFixture>("FixtureMethod"); FixtureResult?fixtureReadyResult = default; fixture.FixtureReady += (_, e) => fixtureReadyResult = e.Result; ((FixtureContainer)Container).Add(fixture); FixtureResult?containerReadyResult = default; Container.FixtureReady += (_, e) => containerReadyResult = e.Result; Container.Ready(); Expect("FixtureReady event should be raised", () => containerReadyResult != null); ExpectedContainerFixtureDescription = FixtureDescriptorAssertion.Of("Simple Fixture", "SimpleFixture", "Carna.TestFixtures+SimpleFixture", typeof(ContextAttribute)); Expect($"the descriptor of the result should be as follows:{ExpectedContainerFixtureDescription.ToDescription()}", () => containerReadyResult != null && FixtureDescriptorAssertion.Of(containerReadyResult.FixtureDescriptor) == ExpectedContainerFixtureDescription); ExpectedContainerFixtureResult = FixtureResultAssertion.ForNullException(false, false, false, 0, 0, FixtureStatus.Ready); Expect($"the result should be as follows:{ExpectedContainerFixtureResult.ToDescription()}", () => containerReadyResult != null && FixtureResultAssertion.Of(containerReadyResult) == ExpectedContainerFixtureResult); Expect("FixtureReady event of the inner fixture should be raised", () => fixtureReadyResult != null); ExpectedFixtureDescription = FixtureDescriptorAssertion.Of("Fixture Method Example", "FixtureMethod", "Carna.TestFixtures+SimpleFixture.FixtureMethod", typeof(ExampleAttribute)); Expect($"the description of the result of the inner fixture should be as follows:{ExpectedFixtureDescription.ToDescription()}", () => fixtureReadyResult != null && FixtureDescriptorAssertion.Of(fixtureReadyResult.FixtureDescriptor) == ExpectedFixtureDescription); ExpectedFixtureResult = FixtureResultAssertion.ForNullException(false, false, false, 0, 0, FixtureStatus.Ready); Expect($"the result of the inner fixture should be as follows:{ExpectedFixtureResult.ToDescription()}", () => fixtureReadyResult != null && FixtureResultAssertion.Of(fixtureReadyResult) == ExpectedFixtureResult); }
void Ex02() { Filter.Accept(Arg.Any <FixtureDescriptor>()).Returns(true); var result = Container.Run(Filter, new FixtureStepRunnerFactory()); Expect( "all inner fixture methods should be called", () => TestFixtures.CalledFixtureMethods.Count == 3 && TestFixtures.CalledFixtureMethods.Contains(typeof(TestFixtures.SimpleFixture)) && TestFixtures.CalledFixtureMethods.Contains(typeof(TestFixtures.SimpleDisposableFixture)) && TestFixtures.CalledFixtureMethods.Contains(typeof(TestFixtures.SimpleFixtureSteppable)) ); ExpectedFixtureDescriptor = FixtureDescriptorWithBackgroundAssertion.Of("Simple Fixture", "SimpleFixture", "Carna.TestFixtures+SimpleFixture", typeof(ContextAttribute), "Simple Fixture Background"); Expect($"the descriptor of the result should be as follows:{ExpectedFixtureDescriptor.ToDescription()}", () => result != null && FixtureDescriptorWithBackgroundAssertion.Of(result.FixtureDescriptor) == ExpectedFixtureDescriptor); ExpectedFixtureResult = FixtureResultAssertion.ForNullException(true, true, true, 0, 3, FixtureStatus.Passed); Expect($"the result should be as follows:{ExpectedFixtureResult.ToDescription()}", () => result != null && FixtureResultAssertion.Of(result) == ExpectedFixtureResult); Expect("FixtureRunning event should be raised", () => FixtureRunningResult != null); ExpectedFixtureRunningDescriptor = FixtureDescriptorAssertion.Of("Simple Fixture", "SimpleFixture", "Carna.TestFixtures+SimpleFixture", typeof(ContextAttribute)); Expect($"the descriptor of the result on FixtureRunning should be as follows:{ExpectedFixtureRunningDescriptor.ToDescription()}", () => FixtureRunningResult != null && FixtureDescriptorAssertion.Of(FixtureRunningResult.FixtureDescriptor) == ExpectedFixtureRunningDescriptor); ExpectedFixtureRunningResult = FixtureResultAssertion.ForNullException(true, false, false, 0, 0, FixtureStatus.Running); Expect($"the result on FixtureRunning should be as follows:{ExpectedFixtureRunningResult.ToDescription()}", () => FixtureRunningResult != null && FixtureResultAssertion.Of(FixtureRunningResult) == ExpectedFixtureRunningResult); Expect("FixtureRun event should be raised", () => FixtureRunResult != null); Expect("the result on FixtureRun event should be the result that is returned by Run method", () => FixtureRunResult == result); }