/// <summary>
 /// Initializes a new instance of the <see cref="DisplayableFeature"/> class using the provided <see cref="Feature"/> to provide initial values.
 /// </summary>
 /// <param name="feature">The <see cref="Feature"/>that should be used when determining the the initial values.</param>
 /// <remarks>This constructor does not wrap the provided feature, it will result in an actual copy with shared scenarios and a shared background.</remarks>
 public DisplayableFeature(Feature feature)
 {
     // Copy the properties from the provided feature
     Title = feature.Title;
     Description = feature.Description;
     Tags = feature.Tags.ToList();
     Scenarios = feature.Scenarios;
     Background = feature.Background;
 }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbFeature"/> class using the provided <see cref="Feature"/> to provide initial values.
        /// </summary>
        /// <param name="feature">The <see cref="Feature"/>that should be used when determining the the initial values.</param>
        /// <param name="group">The group this feature falls under.</param>
        /// <param name="parentTitle">The title of the parent feature.</param>
        /// <param name="version">Version of the feature.</param>
        /// <remarks>This constructor does not wrap the provided feature, it will result in an actual copy with shared scenarios and a shared background.</remarks>
        public DbFeature(Feature feature, string product, string group, string parentTitle, string version)
        {
            Product = product;
            Group = group;
            Version = version;
            ParentTitle = parentTitle;

            // Copy the properties from the provided feature
            Title = feature.Title;
            Description = feature.Description;
            Tags = feature.Tags;
            Scenarios = feature.Scenarios;
            Background = feature.Background;
        }
 /// <summary>
 /// Removes all tags that are recognized as server tags from the provided <see cref="Feature"/>
 /// and all underlying <see cref="Scenario"/>s.
 /// </summary>
 /// <param name="feature">The <see cref="Feature"/> instance </param>
 public static void RemoveServerTags(Feature feature)
 {
     if (feature.Tags != null)
     {
         feature.Tags = RemoveServerTags(feature.Tags);
     }
     if (feature.Scenarios != null)
     {
         foreach (var scenario in feature.Scenarios)
         {
             if (scenario.Tags != null)
             {
                 scenario.Tags = RemoveServerTags(scenario.Tags);
             }
         }
     }
 }
        public async Task<HttpResponseMessage> PostAsync(Feature feature, string branchName, string groupName, string title)
        {
            if (!feature.Title.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
            {
                // NOTE: Using the branchName as product name because of backwards compatability
                await _featureManager.InsertOrUpdateFeatureAsync(feature, branchName, groupName, UNKNOWN_VERSION);
            }
            catch (Exception exception)
            {
                response = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception);
            }

            return response;
        }
        /// <summary>
        /// Gets the parent of the provided feature by parsing the tags.
        /// </summary>
        /// <param name="feature">The <see cref="Feature"/> for which the parent should be determined.</param>
        /// <returns>A <see cref="string"/> containing the title of the feature's parent, or null if the feature has no parent.</returns>
        public string DetermineParent(Feature feature)
        {
            foreach (var tag in feature.Tags)
            {
                string[] tagParts = tag.Split(new[] {":"}, 2, StringSplitOptions.RemoveEmptyEntries);
                if (_childTags.Contains(tagParts[0]))
                {
                    return tagParts[1];
                }
            }

            return null;
        }
 public async Task<HttpResponseMessage> PostAsync(Feature feature, string branchName, string groupName)
 {
     return await PostAsync(feature, branchName, groupName, feature.Title);
 }
        public async Task InsertOrUpdateFeatureAsync(Feature feature, string productName, string groupName, string version)
        {
            var processor = new FeatureProcessor();
            string parentTitle = processor.DetermineParent(feature);

            DbFeature dbFeature = new DbFeature(feature, productName, groupName, parentTitle, version);

            using (var session = Database.DocumentStore.OpenAsyncSession())
            {
                // Using the store method when the feature already exists in the database will override it completely, this is acceptable
                await session.StoreAsync(dbFeature, dbFeature.GetIdentifier());
                await session.SaveChangesAsync();
            }
        }