private TaskExecutionNode CreateMethodNode(TaskExecutionNode classNode, Method method) { var methodNode = new TaskExecutionNode(classNode, method.Task); foreach (var theoryTask in method.TheoryTasks) methodNode.Children.Add(new TaskExecutionNode(methodNode, theoryTask)); return methodNode; }
public When_custom_theory_attribute_skips() { method = testClass.AddMethod("TestMethod1", _ => { }, new[] {Parameter.Create<int>("value")}, new SkippingTheoryAttribute(), new InlineDataAttribute(12), new InlineDataAttribute(33)); theoryTask = method.TheoryTasks[0]; }
public When_class_throws_in_dispose() { // Dispose throws from inside LifetimeCommand and is caught by ExceptionsAndOutputCaptureCommand, // which returns a FailedResult FOR THE METHOD. All of this happens in the scope of running the // method, so this scenario is just a normal failing test method, it just happens that the exception // is thrown from the class's Dispose method, and not from the method itself exception = new InvalidOperationException("Thrown by the class dispose method"); testClass.SetDispose(() => { throw exception; }); method = testClass.AddPassingTest("TestMethod1"); }
public When_class_throws_in_constructor() { // Constructor throws. LifetimeCommand catches and unwraps TargetInvocationException // ExceptionAndOutputCaptureCommand catches and returns a FailedResult FOR THE METHOD. // All of this happens in the scope of running the method, so this scenario is just // a normal failing test method, it just happens that the exception is thrown from // the class constructor, before the method has a chance to execute exception = new InvalidOperationException("Thrown by the class constructor"); testClass.SetConstructor(() => { throw exception; }); method = testClass.AddPassingTest("TestMethod1"); }
public When_custom_before_after_attribute_throws() { // If a BeforeAfterAttribute throws, it's caught and rethrown by BeforeAfterCommand and then // caught by ExceptionAndOutputCaptureCommand, which returns a FailedResult. So this is a normal // failing test method exception = new InvalidOperationException("Thrown by a custom before/after attribute"); method = testClass.AddMethod("TestMethod1", _ => { }, null, new Attribute[] { new FactAttribute(), new CustomBeforeAfterTestAttribute(exception) }); }
public FakeMethodInfo(Method method) { this.method = method; }
public When_custom_fact_attribute_skips() { method = testClass.AddMethod("TestMethod1", _ => { }, null, new SkippingFactAttribute()); }