Exemplo n.º 1
0
        public void StartLaunchTimeout()
        {
            var service = new MockServiceBuilder().Build();

            service.Setup(s => s.Launch.StartAsync(It.IsAny <StartLaunchRequest>())).Throws <TaskCanceledException>();

            var requestExecuterFactory = new MockRequestExecuterFactoryBuilder().Build();

            var launchScheduler = new LaunchReporterBuilder(service.Object).With(requestExecuterFactory.Object);
            var launchReporter  = launchScheduler.Build(1, 1, 1);

            var exp = Assert.ThrowsAny <Exception>(() => launchReporter.Sync());
        }
Exemplo n.º 2
0
        public void FinishTestItemTimeout()
        {
            var service = new MockServiceBuilder().Build();

            service.Setup(s => s.TestItem.FinishAsync(It.IsAny <string>(), It.IsAny <FinishTestItemRequest>())).Throws <TaskCanceledException>();

            var requestExecuterFactory = new MockRequestExecuterFactoryBuilder().Build();

            var launchScheduler = new LaunchReporterBuilder(service.Object).With(requestExecuterFactory.Object);
            var launchReporter  = launchScheduler.Build(1, 1, 1);

            var exp = Assert.ThrowsAny <Exception>(() => launchReporter.Sync());

            Assert.Contains("Cannot finish launch", exp.Message);

            service.Verify(s => s.Launch.FinishAsync(It.IsAny <string>(), It.IsAny <FinishLaunchRequest>()), Times.Never);
        }
Exemplo n.º 3
0
        public void FailedLogsShouldNotAffectFinishingLaunch(int suitesPerLaunch, int testsPerSuite, int logsPerTest)
        {
            var service = new MockServiceBuilder().Build();

            service.Setup(s => s.LogItem.CreateAsync(It.IsAny <CreateLogItemRequest[]>())).Throws <Exception>();

            var requestExecuterFactory = new MockRequestExecuterFactoryBuilder().Build();

            var launchScheduler = new LaunchReporterBuilder(service.Object).With(requestExecuterFactory.Object);
            var launchReporter  = launchScheduler.Build(suitesPerLaunch, testsPerSuite, logsPerTest);

            launchReporter.Sync();

            service.Verify(s => s.Launch.StartAsync(It.IsAny <StartLaunchRequest>()), Times.Exactly(1));
            service.Verify(s => s.TestItem.StartAsync(It.IsAny <StartTestItemRequest>()), Times.Exactly(suitesPerLaunch));
            service.Verify(s => s.TestItem.StartAsync(It.IsAny <string>(), It.IsAny <StartTestItemRequest>()), Times.Exactly(testsPerSuite * suitesPerLaunch));
            service.Verify(s => s.TestItem.FinishAsync(It.IsAny <string>(), It.IsAny <FinishTestItemRequest>()), Times.Exactly(testsPerSuite * suitesPerLaunch + suitesPerLaunch));
            service.Verify(s => s.Launch.FinishAsync(It.IsAny <string>(), It.IsAny <FinishLaunchRequest>()), Times.Once);
        }
Exemplo n.º 4
0
        public void FailedStartSuiteItemShouldRaiseExceptionAtFinishLaunch(int suitesPerLaunch, int testsPerSuite, int logsPerTest)
        {
            var service = new MockServiceBuilder().Build();

            service.Setup(s => s.TestItem.StartAsync(It.IsAny <StartTestItemRequest>())).Throws <Exception>();

            var requestExecuterFactory = new MockRequestExecuterFactoryBuilder().Build();

            var launchScheduler = new LaunchReporterBuilder(service.Object).With(requestExecuterFactory.Object);
            var launchReporter  = launchScheduler.Build(suitesPerLaunch, testsPerSuite, logsPerTest);

            var exp = Assert.ThrowsAny <Exception>(() => launchReporter.Sync());

            Assert.Contains("Cannot finish launch", exp.Message);

            service.Verify(s => s.TestItem.StartAsync(It.IsAny <StartTestItemRequest>()), Times.Exactly(suitesPerLaunch));
            service.Verify(s => s.TestItem.StartAsync(null, It.IsAny <StartTestItemRequest>()), Times.Never);
            service.Verify(s => s.TestItem.FinishAsync(null, It.IsAny <FinishTestItemRequest>()), Times.Never);
        }