Beispiel #1
0
        public void RunTests_ParallelTestExecution_SpeedsUpTestExecution()
        {
            MockOptions.Setup(o => o.ParallelTestExecution).Returns(false);

            Stopwatch            stopwatch  = new Stopwatch();
            TestExecutor         executor   = new TestExecutor(TestEnvironment);
            IEnumerable <string> testsToRun = SampleTests.Yield();

            stopwatch.Start();
            executor.RunTests(testsToRun, MockRunContext.Object, MockFrameworkHandle.Object);
            stopwatch.Stop();
            long sequentialDuration = stopwatch.ElapsedMilliseconds;

            MockOptions.Setup(o => o.ParallelTestExecution).Returns(true);
            MockOptions.Setup(o => o.MaxNrOfThreads).Returns(Environment.ProcessorCount);

            executor   = new TestExecutor(TestEnvironment);
            testsToRun = SampleTests.Yield();
            stopwatch.Restart();
            executor.RunTests(testsToRun, MockRunContext.Object, MockFrameworkHandle.Object);
            stopwatch.Stop();
            long parallelDuration = stopwatch.ElapsedMilliseconds;

            Assert.IsTrue(sequentialDuration > 4000, sequentialDuration.ToString()); // 2 long tests, 2 seconds per test
            Assert.IsTrue(parallelDuration > 2000, parallelDuration.ToString());
            Assert.IsTrue(parallelDuration < 3500, parallelDuration.ToString());     // 2 seconds per long test + some time for the rest
        }
Beispiel #2
0
        public SampleWorkflow(Sample sample, DataLocker <Sample> locker) : base(sample, locker)
        {
            int id = sample.Id;

            SampleTests.AddFilter(() => e => e.SampleId == id);

            var task = UpdateChildsAsync();

            SetState(sample.Stage);
        }
Beispiel #3
0
        public SampleWorkflow(Sample sample, DataLocker <Sample> locker) : base(sample, locker)
        {
            var id = sample.Id;

            SampleTests.AddFilter(() => e => e.SampleId == id);

            H <SampleWorkflow> .Initialize(this);

            var task = UpdateChildrenAsync();

            SetState(sample.Stage);
        }
Beispiel #4
0
        public async Task UpdateChildsAsync()
        {
            await SampleTests.UpdateAsync();

            Update();
        }