public void CanStartAndEndSpecification() { var sink = Substitute.For <IExecutionListener>(); var elements = new ISpecificationElement[] { ElementFixtures.Specification1, ElementFixtures.Behavior1Specification1, ElementFixtures.Behavior1Specification2 }; var cache = new ElementCache(elements); var tracker = new RunTracker(elements); var listener = new ExecutionAdapterRunListener(sink, cache, tracker); var context = new TestContextInfo(ElementFixtures.Context.TypeName, string.Empty); var specification = new TestSpecificationInfo(ElementFixtures.Context.TypeName, ElementFixtures.Specification1.FieldName, string.Empty); listener.OnContextStart(context); listener.OnSpecificationStart(specification); listener.OnSpecificationEnd(specification, new TestRunResult(TestStatus.Passing)); listener.OnContextEnd(context); sink.Received().OnContextStart(ElementFixtures.Context); sink.Received().OnSpecificationStart(ElementFixtures.Specification1); sink.Received().OnSpecificationEnd(ElementFixtures.Specification1, Arg.Any <string>(), Arg.Any <TestRunResult>()); sink.Received().OnContextEnd(ElementFixtures.Context, Arg.Any <string>()); }
public static MspecRemoteTask GetRemoteTask(IMspecElement element) { return(element switch { IContextElement context => FromContext(context), IBehaviorElement behavior => FromBehavior(behavior), ISpecificationElement specification => FromSpecification(specification), _ => throw new ArgumentOutOfRangeException(nameof(element)) });
public static MspecReSharperId Create(IMspecElement element) { return(element switch { IContextElement context => new MspecReSharperId(context), ISpecificationElement specification => new MspecReSharperId(specification), IBehaviorElement behavior => new MspecReSharperId(behavior), _ => throw new ArgumentOutOfRangeException(nameof(element)) });
public static string Self(ISpecificationElement specification) { return(new MspecReSharperId(specification).Id); }
public MspecReSharperId(ISpecificationElement specification) { Id = specification.Behavior != null ? $"{specification.Context.TypeName}.{specification.Behavior.FieldName}.{specification.FieldName}" : $"{specification.Context.TypeName}.{specification.FieldName}"; }