Beispiel #1
0
        public async Task PersistFeatureTestResultAsync(FeatureTestResult testResult, string productName, string groupName, string version)
        {
            // TODO Save testresults per version
            using (var session = _storeProvider.Store.OpenAsyncSession())
            {
                var dbFeature = await session.Query <Features_ByTitleProductAndGroup.QueryModel, Features_ByTitleProductAndGroup>()
                                .Where(f => f.Product == productName &&
                                       f.Group == groupName &&
                                       f.Title == testResult.FeatureTitle &&
                                       f.Version == version)
                                .OfType <DbFeature>()
                                .SingleOrDefaultAsync();

                if (dbFeature == null)
                {
                    throw new Exception(String.Format(CultureInfo.InvariantCulture,
                                                      "Feature {0} does not exist for product {1} under group {2}.",
                                                      testResult.FeatureTitle,
                                                      productName,
                                                      groupName));
                }

                dbFeature.TestResult = testResult;

                await session.SaveChangesAsync();
            }
        }
        public async Task CanPersistTestResults()
        {
            // Arrange
            var documentStoreProvider = DocumentStoreProvider;
            var expectedTestResults   = new FeatureTestResult
            {
                FeatureTitle      = "My Feature",
                Result            = TestResult.Passed,
                TestExecutionDate = DateTime.Now
            };

            using (var session = documentStoreProvider.Store.OpenAsyncSession())
            {
                await session.StoreDbFeatureAsync("MyProduct", "MyGroup", "My Feature", "0.0.0");

                await session.SaveChangesAsync();
            }

            // Act
            var sut = new FeatureManager(documentStoreProvider, configurationManager, logger);
            await sut.PersistFeatureTestResultAsync(expectedTestResults, "MyProduct", "MyGroup", "0.0.0");

            // Assert
            using (var session = documentStoreProvider.Store.OpenAsyncSession())
            {
                var dbFeature = await session.LoadAsync <DbFeature>(DbFeatureExtensions.GetIdentifier("MyProduct", "MyGroup", "My Feature", "0.0.0"));

                dbFeature.ShouldNotBeNull();
                dbFeature.TestResult.ShouldNotBeNull();
                dbFeature.TestResult.Result.ShouldBe(TestResult.Passed);
                dbFeature.TestResult.TestExecutionDate.ShouldBe(expectedTestResults.TestExecutionDate);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
0
 public FeatureTestRun(MethodInfo method, Type frameworkType, FeatureTestResult result, string message = null, Exception exception = null)
 {
     this.Method        = method;
     this.FrameworkType = frameworkType;
     this.Result        = result;
     this.Message       = message;
     this.Exception     = exception;
 }
        public async Task <ActionResult <FeatureTestResult> > PostAsync([FromBody] FeatureTestResult testResult, string branchName, string groupName, string title)
        {
            if (!testResult.FeatureTitle.Equals(title, StringComparison.OrdinalIgnoreCase))
            {
                return(BadRequest("The title provided by the POST data and the title in uri do not match!"));
            }

            await _featureManager.PersistFeatureTestResultAsync(testResult, branchName, groupName, UNKNOWN_VERSION);

            return(CreatedAtRoute("GetFeature", null));
        }
        public async Task ThrowsWhenStoringTestResultsForNonExistingFeature()
        {
            // Arrange
            var documentStoreProvider = DocumentStoreProvider;
            var expectedTestResults   = new FeatureTestResult
            {
                FeatureTitle      = "My Feature",
                Result            = TestResult.Passed,
                TestExecutionDate = DateTime.Now
            };

            // Act
            var sut       = new FeatureManager(documentStoreProvider, configurationManager, logger);
            var exception = await Should.ThrowAsync <Exception>(sut.PersistFeatureTestResultAsync(expectedTestResults, "MyProduct", "MyGroup", "0.0.0"));

            // Assert
            exception.Message.ShouldContain(expectedTestResults.FeatureTitle);
            exception.Message.ShouldContain("MyProduct");
            exception.Message.ShouldContain("MyGroup");
        }
Beispiel #7
0
        public async Task PersistFeatureTestResultAsync(FeatureTestResult testResult, string productName, string groupName, string version)
        {
            using (var session = Database.DocumentStore.OpenAsyncSession())
            {
                var dbFeature = await session.LoadAsync <DbFeature>(DbFeatureExtensions.GetIdentifier(productName, groupName, testResult.FeatureTitle, version));

                if (dbFeature == null)
                {
                    throw new Exception(String.Format(CultureInfo.InvariantCulture,
                                                      "Feature {0} does not exist for product {1} under group {2}.",
                                                      testResult.FeatureTitle,
                                                      productName,
                                                      groupName));
                }

                dbFeature.TestResult = testResult;

                await session.SaveChangesAsync();
            }
        }
Beispiel #8
0
        public async Task <HttpResponseMessage> PostAsync(FeatureTestResult testResult, string branchName, string groupName, string title)
        {
            if (!testResult.FeatureTitle.Equals(title, StringComparison.OrdinalIgnoreCase))
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "The title provided by the POST data and the title in uri do not match!"));
            }

            var response = Request.CreateResponse(HttpStatusCode.Created);

            try
            {
                await _featureManager.PersistFeatureTestResultAsync(testResult, branchName, groupName, UNKNOWN_VERSION);
            }
            catch (Exception exception)
            {
                response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception);
            }

            return(response);
        }