public async Task BigAsyncRealTreeWithEmptySuites() { var launchScheduler = new LaunchReporterBuilder(_service); var launchReporter = launchScheduler.Build(10, 0, 0); launchReporter.Sync(); var launch = await _service.Launch.GetAsync(launchReporter.Info.Uuid); await _service.Launch.DeleteAsync(launch.Id); }
public async Task BigAsyncRealTree() { var extManager = new ExtensionManager(); var launchScheduler = new LaunchReporterBuilder(_service).With(extManager); var launchReporter = launchScheduler.Build(1, 20, 20); launchReporter.Sync(); var launch = await _service.Launch.GetAsync(launchReporter.Info.Uuid); await _service.Launch.DeleteAsync(launch.Id); }
public void StartTestItemTimeout() { var service = new MockServiceBuilder().Build(); service.Setup(s => s.TestItem.StartAsync(It.IsAny <string>(), It.IsAny <StartTestItemRequest>())).Throws <TaskCanceledException>(); var launchScheduler = new LaunchReporterBuilder(service.Object).With(new MockRequestExecuterFactoryBuilder().Build().Object); var launchReporter = launchScheduler.Build(1, 1, 1); var exp = Assert.ThrowsAny <Exception>(() => launchReporter.Sync()); Assert.Contains("Cannot finish launch", exp.Message); }
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()); }
public void SuccessReporting(int suitesPerLaunch, int testsPerSuite, int logsPerTest) { var service = new MockServiceBuilder().Build(); var launchScheduler = new LaunchReporterBuilder(service.Object); var launchReporter = launchScheduler.Build(suitesPerLaunch, testsPerSuite, logsPerTest); launchReporter.Sync(); 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)); launchReporter.ChildTestReporters.Select(s => s.Info.Uuid).Should().OnlyHaveUniqueItems(); launchReporter.ChildTestReporters.SelectMany(s => s.ChildTestReporters).Select(t => t.Info.Uuid).Should().OnlyHaveUniqueItems(); }
public void ShouldInvokeFormatLogMethod() { var service = new MockServiceBuilder().Build(); var logFormatter = new Mock <ILogFormatter>(); var extensionManager = new Mock <IExtensionManager>(); extensionManager.Setup(p => p.LogFormatters).Returns(new List <ILogFormatter> { logFormatter.Object }); var launchScheduler = new LaunchReporterBuilder(service.Object).With(extensionManager.Object); var launchReporter = launchScheduler.Build(1, 1, 1); launchReporter.Sync(); logFormatter.Verify(lf => lf.FormatLog(It.IsAny <CreateLogItemRequest>()), Times.Once); }
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); }
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); }
public void LogsReportingShouldBeOneByOne() { var requests = new ConcurrentBag <CreateLogItemRequest[]>(); var service = new MockServiceBuilder().Build(); service.Setup(s => s.LogItem.CreateAsync(It.IsAny <CreateLogItemRequest[]>())).ReturnsAsync(new LogItemsCreatedResponse()) .Callback <CreateLogItemRequest[]>((arg) => requests.Add(arg)); var launchScheduler = new LaunchReporterBuilder(service.Object); var launchReporter = launchScheduler.Build(1, 30, 30); launchReporter.Sync(); service.Verify(s => s.Launch.FinishAsync(It.IsAny <string>(), It.IsAny <FinishLaunchRequest>()), Times.Once); service.Verify(s => s.LogItem.CreateAsync(It.IsAny <CreateLogItemRequest[]>()), Times.AtLeast(30 * 30 / 10)); // logs buffer size foreach (var bufferedRequests in requests) { bufferedRequests.Select(r => r.Text).Should().BeInAscendingOrder(); } }