예제 #1
0
        public void CanStartAndEndBehaviorSpecification()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context,
                RemoteTaskFixtures.Behavior1,
                RemoteTaskFixtures.Behavior1Specification1
            });
            var cache = new ElementCache(new ISpecificationElement[]
            {
                ElementFixtures.Behavior1Specification1
            });

            var sink    = Substitute.For <ITestExecutionSink>();
            var context = new RunContext(depot, sink);

            var listener = new TestExecutionListener(context, cache, CancellationToken.None);

            listener.OnContextStart(ElementFixtures.Context);
            listener.OnBehaviorStart(ElementFixtures.Behavior1);
            listener.OnSpecificationStart(ElementFixtures.Behavior1Specification1);
            listener.OnSpecificationEnd(ElementFixtures.Behavior1Specification1, string.Empty, new TestRunResult(TestStatus.Passing));
            listener.OnBehaviorEnd(ElementFixtures.Behavior1, string.Empty);
            listener.OnContextEnd(ElementFixtures.Context, string.Empty);

            sink.Received(1).TestStarting(RemoteTaskFixtures.Context);
            sink.Received(1).TestStarting(RemoteTaskFixtures.Behavior1);
            sink.Received(1).TestStarting(RemoteTaskFixtures.Behavior1Specification1);
            sink.Received(1).TestFinished(RemoteTaskFixtures.Behavior1Specification1, Arg.Any <string>(), TestResult.Success);
            sink.Received(1).TestFinished(RemoteTaskFixtures.Behavior1, Arg.Any <string>(), TestResult.Success);
            sink.Received(1).TestFinished(RemoteTaskFixtures.Context, Arg.Any <string>(), TestResult.Success);
        }
예제 #2
0
        public Executor(ITestExecutionSink executionSink, TestRunRequest request, RemoteTaskDepot depot, CancellationToken token)
        {
            this.request = request;
            this.token   = token;

            context = new RunContext(depot, executionSink);
        }
예제 #3
0
 public Discoverer(TestRequest request, IMspecController controller, ITestDiscoverySink sink, RemoteTaskDepot depot, CancellationToken token)
 {
     this.request    = request;
     this.controller = controller;
     this.sink       = sink;
     this.depot      = depot;
     this.token      = token;
 }
        public void CanGetContextByElement()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context
            });

            Assert.NotNull(depot[ElementFixtures.Context]);
        }
        public void CanGetBehaviorByElement()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context,
                RemoteTaskFixtures.Behavior1
            });

            Assert.NotNull(depot[ElementFixtures.Behavior1]);
        }
        public void CanGetSpecificationByElement()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context,
                RemoteTaskFixtures.Specification1
            });

            Assert.NotNull(depot[ElementFixtures.Specification1]);
        }
        public void CanGetBehaviorWhenThereIsSpecificationWithSameName()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context,
                RemoteTaskFixtures.Behavior1,
                RemoteTaskFixtures.Specification1,
                RemoteTaskFixtures.Behavior1Specification1
            });

            Assert.NotNull(depot[ElementFixtures.Specification1]);
        }
예제 #8
0
        public void TaskNotInDepotIsReportedToSink()
        {
            var sink = Substitute.For <ITestExecutionSink>();

            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context
            });

            var context = new RunContext(depot, sink);

            Assert.That(context.GetTask(ElementFixtures.Specification1), Is.Not.Null);
            sink.Received().DynamicTestDiscovered(Arg.Any <RemoteTask>());
        }
예제 #9
0
        public void CanStartAndEndContext()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context
            });
            var cache = new ElementCache(Array.Empty <ISpecificationElement>());

            var sink    = Substitute.For <ITestExecutionSink>();
            var context = new RunContext(depot, sink);

            var listener = new TestExecutionListener(context, cache, CancellationToken.None);

            listener.OnContextStart(ElementFixtures.Context);
            listener.OnContextEnd(ElementFixtures.Context, string.Empty);

            sink.Received(1).TestStarting(RemoteTaskFixtures.Context);
            sink.Received(1).TestFinished(RemoteTaskFixtures.Context, Arg.Any <string>(), TestResult.Success);
        }
        public void BoundElementsAreRunnable()
        {
            var depot = new RemoteTaskDepot(new RemoteTask[]
            {
                RemoteTaskFixtures.Context,
                RemoteTaskFixtures.Behavior1,
                RemoteTaskFixtures.Specification1,
                RemoteTaskFixtures.Behavior1Specification1
            });

            depot.Bind(ElementFixtures.Context, RemoteTaskFixtures.Context);
            depot.Bind(ElementFixtures.Behavior1, RemoteTaskFixtures.Behavior1);
            depot.Bind(ElementFixtures.Specification1, RemoteTaskFixtures.Specification1);
            depot.Bind(ElementFixtures.Behavior1Specification1, RemoteTaskFixtures.Behavior1Specification1);

            var selected = depot.GetTestsToRun().ToArray();

            CollectionAssert.Contains(selected, ElementFixtures.Specification1);
            CollectionAssert.Contains(selected, ElementFixtures.Behavior1Specification1);
        }
        public void UnreportedBehaviorsAreAddedToDepot()
        {
            var container = new TestContainer("assembly.dll", ShadowCopy.None);
            var request   = new TestDiscoveryRequest(container);

            var controller = Substitute.For <IMspecController>();
            var sink       = Substitute.For <ITestDiscoverySink>();
            var depot      = new RemoteTaskDepot(GetReportedTasks().ToArray());
            var discoverer = new Discoverer(request, controller, sink, depot, CancellationToken.None);

            var elements = GetDiscoveredElements().ToArray();

            controller.Find(Arg.Do <IMspecDiscoverySink>(x => PopulateSink(x, elements)), Arg.Any <string>());

            discoverer.Discover();

            foreach (var element in elements)
            {
                Assert.NotNull(depot[element]);
            }
        }