Esempio n. 1
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;
        }
Esempio n. 2
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();
            }
        }