public NSpecExampleTest( ExampleBase example ) : base( example.Spec, null ) { this.Kind = TestKinds.Test; this.IsTestCase = true; this._example = example; }
public void AddExample(ExampleBase example) { example.Context = this; example.Tags.AddRange(Tags); Examples.Add(example); example.Pending |= IsPending(); }
public void Write(ExampleBase example, int level) { var result = example.Failed() ? new TestResultDTO { Outcome = TestOutcome.Failed, StackTrace = example.Exception.StackTrace, Message = example.Exception.Message } : new TestResultDTO { Outcome = example.Pending ? TestOutcome.Skipped : TestOutcome.Passed }; result.TestName = example.FullName(); result.Source = this.Source; this.observer.Receive(result); }
NSpecExampleTest CreateGallioTestFrom(ExampleBase nspecExample) { try { NSpecExampleTest exampleTest = new NSpecExampleTest(nspecExample); return exampleTest; } catch { throw new Exception(String.Format("Error adding example {0}", nspecExample.Spec)); } }
public MethodInfo GetAction(ExampleBase example) { if (example is MethodExample) { return example.GetType() .GetField("method", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(example) as MethodInfo; } var action = example.GetType() .GetField("action", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(example) as Action; return action.Method; }
public void Write(ExampleBase e, int level) { string name = string.Empty; Utilities.GenerateUniqueExampleName(e.Context, ref name, e.Spec); if (ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(e))) { var noFailure = e.Exception == null; var failureMessage = noFailure ? "" : " - FAILED - {0}".With(e.Exception.CleanMessage()); var whiteSpace = indent.Times(level); var result = e.Pending ? whiteSpace + e.Spec + " - PENDING" : whiteSpace + e.Spec + failureMessage; WriteLineDelegate(result); if (ExampleProcessed != null) ExampleProcessed(new ExampleEventArgs(e)); } }
public void Exercise(ExampleBase example, nspec nspec) { if (example.ShouldSkip(nspec.tagsFilter)) { return; } RunAndHandleException(RunBefores, nspec, ref Exception); RunAndHandleException(RunActs, nspec, ref Exception); RunAndHandleException(example.Run, nspec, ref example.Exception); bool exceptionThrownInAfters = RunAndHandleException(RunAfters, nspec, ref Exception); // when an expected exception is thrown and is set to be cleared by 'expect<>', // a subsequent exception thrown in 'after' hooks would go unnoticed, so do not clear in this case if (exceptionThrownInAfters) { ClearExpectedException = false; } }
public RunnableExample(Context context, ExampleBase example) { this.context = context; this.example = example; }
void ILiveFormatter.Write(ExampleBase e, int level) { base.Write(e, level); }
public void Exercise(ExampleBase example, nspec nspec) { if (example.ShouldSkip(nspec.tagsFilter)) return; RunAndHandleException(RunBefores, nspec, ref Exception); RunAndHandleException(RunActs, nspec, ref Exception); RunAndHandleException(example.Run, nspec, ref example.Exception); bool exceptionThrownInAfters = RunAndHandleException(RunAfters, nspec, ref Exception); // when an expected exception is thrown and is set to be cleared by 'expect<>', // a subsequent exception thrown in 'after' hooks would go unnoticed, so do not clear in this case if (exceptionThrownInAfters) ClearExpectedException = false; }
public void Exercise(ExampleBase example, nspec nspec) { if (example.ShouldSkip(nspec.tagsFilter)) return; RunAndHandleException(RunBefores, nspec, ref Exception); RunAndHandleException(RunActs, nspec, ref Exception); RunAndHandleException(example.Run, nspec, ref example.Exception); RunAndHandleException(RunAfters, nspec, ref Exception); example.AssignProperException(Exception); }
public ExampleEventArgs(ExampleBase ex) { string name = string.Empty; Utilities.GenerateUniqueExampleName(ex.Context,ref name,ex.Spec); Example = new SerializableExampleBase { Spec = ex.Spec, Exception = ex.Exception != null ? new SerializableExampleFailureException { ExampleException = ex.Exception.GetBaseException() } : null, Context = new SerializableContext { Name = ex.Context.Name, Tags = ex.Context.Tags }, Tags = ex.Tags, UniqueName = name }; }
private string GetSpecName(ExampleBase e) { string name = string.Empty; Utilities.GenerateUniqueExampleName(e.Context, ref name, e.Spec); return name; }
public string WriteFailure(ExampleBase example) { var failure = "\n" + example.FullName().Replace("_", " ") + "\n"; failure += example.Exception.CleanMessage() + "\n"; var stackTrace = FailureLines(example.Exception); stackTrace.AddRange(FailureLines(example.Exception.InnerException)); var flattenedStackTrace = stackTrace.Flatten("\n").TrimEnd() + "\n"; failure += example.Context.GetInstance().StackTraceToPrint(flattenedStackTrace); return failure; }
public void Write(ExampleBase example, int level) { WrittenExamples.Add(example); }