Ejemplo n.º 1
0
        public void AddEnvironmentForTest()
        {
            var notifications = new List<TestCompletedNotification>();
            var builder = new Mock<IReportBuilder>();
            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            var environment = new Mock<IActiveEnvironment>();
            {
                environment.Setup(e => e.Environment)
                    .Returns("a");
            }

            storage.AddEnvironmentForTest(testId, environment.Object);

            Assert.That(
                storage.EnvironmentsForTest(testId),
                Is.EquivalentTo(
                    new List<IActiveEnvironment>
                        {
                            environment.Object
                        }));
        }
Ejemplo n.º 2
0
        public void EnvironmentFailure()
        {
            var notifications = new List<TestCompletedNotification>();
            var builder = new Mock<IReportBuilder>();
            {
                builder.Setup(b => b.AddToSection(It.IsAny<string>(), It.IsAny<IEnumerable<TestSection>>()))
                    .Verifiable();
            }

            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testCompleted = false;
            var testResult = TestExecutionResult.None;
            storage.OnTestCompletion +=
                (s, e) =>
                {
                    testCompleted = true;
                    testResult = e.Result;
                };

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            var environmentId = "a";
            var firstEnvironment = new Mock<IActiveEnvironment>();
            {
                firstEnvironment.Setup(e => e.Environment)
                    .Returns(environmentId);
                firstEnvironment.Setup(e => e.Terminate())
                    .Verifiable();
            }

            var secondEnvironment = new Mock<IActiveEnvironment>();
            {
                secondEnvironment.Setup(e => e.Environment)
                    .Returns(environmentId);
                secondEnvironment.Setup(e => e.Terminate())
                    .Verifiable();
            }

            storage.AddEnvironmentForTest(testId, firstEnvironment.Object);
            storage.AddEnvironmentForTest(testId, secondEnvironment.Object);

            storage.EnvironmentFailure(testId, environmentId);

            Assert.IsTrue(testCompleted);
            Assert.AreEqual(TestExecutionResult.Failed, testResult);
            firstEnvironment.Verify(e => e.Terminate(), Times.Once());
            secondEnvironment.Verify(e => e.Terminate(), Times.Once());
        }
Ejemplo n.º 3
0
        public void HandleEnvironmentTestCompletion()
        {
            var notifications = new List<TestCompletedNotification>();
            var builder = new Mock<IReportBuilder>();
            {
                builder.Setup(b => b.AddToSection(It.IsAny<string>(), It.IsAny<IEnumerable<TestSection>>()))
                    .Verifiable();
            }

            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testCompleted = false;
            storage.OnTestCompletion += (s, e) => testCompleted = true;

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            var environment = new Mock<IActiveEnvironment>();
            {
                environment.Setup(e => e.Environment)
                    .Returns("a");
            }

            storage.AddEnvironmentForTest(testId, environment.Object);

            environment.Raise(e => e.OnTestCompletion += null, new TestExecutionResultEventArgs(testId, TestExecutionResult.Failed));
            Assert.IsTrue(testCompleted);
        }
Ejemplo n.º 4
0
        public void HandleEnvironmentExecutionProgress()
        {
            var notifications = new List<TestCompletedNotification>();
            var builder = new Mock<IReportBuilder>();
            {
                builder.Setup(b => b.AddToSection(It.IsAny<string>(), It.IsAny<IEnumerable<TestSection>>()))
                    .Verifiable();
            }

            var diagnostics = new SystemDiagnostics((p, s) => { }, null);
            var storage = new ActiveTestStorage(diagnostics);

            var testId = 10;
            storage.Add(testId, builder.Object, notifications);

            var environment = new Mock<IActiveEnvironment>();
            {
                environment.Setup(e => e.Environment)
                    .Returns("a");
            }

            storage.AddEnvironmentForTest(testId, environment.Object);

            environment.Raise(
                e => e.OnExecutionProgress += null,
                new TestExecutionProgressEventArgs(
                    testId,
                    "a",
                    new TestSection(
                        "b",
                        DateTimeOffset.Now,
                        DateTimeOffset.Now,
                        false,
                        Enumerable.Empty<DateBasedTestInformation>(),
                        Enumerable.Empty<DateBasedTestInformation>(),
                        Enumerable.Empty<DateBasedTestInformation>())));
            builder.Verify(b => b.AddToSection(It.IsAny<string>(), It.IsAny<IEnumerable<TestSection>>()), Times.Once());
        }