public async Task CanGetDbFeaturesByProductAndVersionAsync() { // Arrange var documentStoreProvider = DocumentStoreProvider; await documentStoreProvider.Store.ExecuteIndexAsync(new Features_ByTitleProductAndGroup()); using (var session = documentStoreProvider.Store.OpenAsyncSession()) { await session.StoreDbFeatureAsync("MyProduct", "MyGroup", "MyFirstFeature", "0.0.0"); await session.StoreDbFeatureAsync("MyProduct", "MyGroup", "MyFirstFeature", "1.0.0"); await session.StoreDbFeatureAsync("MyProduct", "MyGroup", "MySecondFeature", "1.0.0"); await session.SaveChangesAsync(); } WaitForIndexing(documentStoreProvider.Store); // Act var sut = new FeatureManager(documentStoreProvider, configurationManager, logger); var result = await sut.GetDbFeaturesByProductAndVersionAsync("MyProduct", "1.0.0"); // Assert result.ShouldNotBeNull(); result.Count().ShouldBe(2); result.FirstOrDefault()?.Title.ShouldBe("MyFirstFeature"); result.FirstOrDefault()?.Version.ShouldBe("1.0.0"); result.LastOrDefault()?.Title.ShouldBe("MySecondFeature"); result.LastOrDefault()?.Version.ShouldBe("1.0.0"); }
public async Task CanPersistTestResults() { // Arrange var documentStoreProvider = DocumentStoreProvider; var expectedTestResults = new FeatureTestResult { FeatureTitle = "My Feature", Result = TestResult.Passed, TestExecutionDate = DateTime.Now }; await documentStoreProvider.StoreDbFeatureAsync("MyProduct", "MyGroup", "My Feature", "0.0.0"); WaitForIndexing(documentStoreProvider.Store); // Act var sut = new FeatureManager(documentStoreProvider, logger); await sut.PersistFeatureTestResultAsync(expectedTestResults, "MyProduct", "MyGroup", "0.0.0"); // Assert using (var session = documentStoreProvider.Store.OpenAsyncSession()) { var dbFeature = (await sut.GetDbFeaturesByProductAndVersionAsync("MyProduct", "0.0.0")).Single(); dbFeature.TestResult.ShouldNotBeNull(); dbFeature.TestResult.Result.ShouldBe(TestResult.Passed); dbFeature.TestResult.TestExecutionDate.ShouldBe(expectedTestResults.TestExecutionDate); } }
public async Task CanGetDbFeaturesByProductAndVersionAsync() { // Arrange var documentStoreProvider = DocumentStoreProvider; await documentStoreProvider.Store.ExecuteIndexAsync(new Features_ByTitleProductAndGroup()); await documentStoreProvider.StoreDbFeatureAsync("MyProduct", "MyGroup", "MyFirstFeature", "0.0.0"); await documentStoreProvider.StoreDbFeatureAsync("MyProduct", "MyGroup", "MyFirstFeature", "1.0.0"); await documentStoreProvider.StoreDbFeatureAsync("MyProduct", "MyGroup", "MySecondFeature", "1.0.0"); await documentStoreProvider.StoreDbFeatureAsync("MyProduct", "MyGroup", "MyThirdFeature", "0.0.0"); WaitForIndexing(documentStoreProvider.Store); // Act var sut = new FeatureManager(documentStoreProvider, logger); var result = await sut.GetDbFeaturesByProductAndVersionAsync("MyProduct", "1.0.0"); // Assert result.ShouldNotBeNull(); result.Count().ShouldBe(2); result.First().Title.ShouldBe("MyFirstFeature"); result.First().Versions.ShouldNotBeNull(); result.First().Versions.Length.ShouldBe(2); result.First().Versions.ShouldContain("0.0.0"); result.First().Versions.ShouldContain("1.0.0"); result.Last().Title.ShouldBe("MySecondFeature"); result.Last().Versions.ShouldNotBeNull(); result.Last().Versions.Length.ShouldBe(1); result.Last().Versions.ShouldContain("1.0.0"); }
/// <summary> /// Processes all analysis reports and features for the provided <paramref name="productName">product</paramref> at the provided <paramref name="version"/> /// and stores the results of the analysis. /// </summary> /// <param name="productName">Name of the product to process.</param> /// <param name="version">Version of the product to process.</param> public async Task AnalyzeAndPersistResultsAsync(string productName, string version) { // Because we will analyze the entire product, remove the old results await _analysisReportManager.DeleteDbInvocationsAsync(productName, version); // Collect all features for the provided product/version combination IEnumerable <DbFeature> features = await _featureManager.GetDbFeaturesByProductAndVersionAsync(productName, version); // Collect all analysisreports for the provided product/version combination IEnumerable <AnalysisReport> reports = _analysisReportManager.GetAnalysisReportsByProductAndVersionAsync(productName, version); if (reports.Any()) { // Analyze the features based on the provided report await AnalyzeAndPersistAsync(productName, version, features, reports); } }