public void Should_be_able_to_AND_two_filters() { var eventsInQueue = new Queue <GherkinEvent>(); eventsInQueue.Enqueue(new FeatureEvent(new Feature("feature title"), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag1", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title t1", ""), e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new TagEvent("@tag1", e => { })); eventsInQueue.Enqueue(new TagEvent("@tag2", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title t2", ""), e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new EofEvent(e => { })); var events = GroupEventsByTag.GroupByTag(eventsInQueue); var filter1 = new OrFilter(new[] { "@tag1" }); var filter2 = new OrFilter(new[] { "@tag2" }); var filter = new AndFilter(filter1, filter2); var filteredEvents = filter.Filter(events).ToList(); Assert.AreEqual(4, filteredEvents.Count); var scenarioEvents = filteredEvents.Where(_ => _ is ScenarioEvent).ToList(); Assert.AreEqual(1, scenarioEvents.Count()); CollectionAssert.AreEqual(new[] { "@tag1", "@tag2" }, scenarioEvents[0].Tags); }
public void tags_in_each_item_in_list_is_ORed_together() { var tagsToFilter = new List <string[]> { new[] { "@tag1", "@tag2" } }; var filter = TagFilterBuilder.Build(tagsToFilter); var eventsInQueue = new Queue <GherkinEvent>(); eventsInQueue.Enqueue(new FeatureEvent(new Feature("title"), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag1", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag3", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag2", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag3", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new EofEvent(e => { })); var events = GroupEventsByTag.GroupByTag(eventsInQueue); var filteredEvents = filter.Filter(events).ToList(); Assert.AreEqual(4, filteredEvents.Count); //no events with tag3 Assert.IsFalse(filteredEvents.Any(_ => _.Tags.Any(t => t == "@tag3"))); }
private IEnumerable <GherkinEvent> FilterByTag() { var eventsByTag = GroupEventsByTag.GroupByTag(this.events); var eventsToRaise = new List <GherkinEvent>(); while (eventsByTag.Any()) { var eventsToHandle = new Queue <GherkinEvent>(GroupEventsByFeature.GetEventsForNextFeature(eventsByTag).ToList()); var tagsFilter = TagFilterBuilder.Build(configuration.TagsFilter); var filteredEvents = tagsFilter.Filter(eventsToHandle).ToList(); eventsToRaise.AddRange(filteredEvents); } return(eventsToRaise); }
public void Events_with_no_tags_returns_all_Events() { var feature = new Feature("title", "src"); var expected = new List <GherkinEvent> { new FeatureEvent(feature, e => { }), new ScenarioEvent(new Scenario("title", feature.Source, feature), e => { }), new StepEvent("step", e => { }), new EofEvent(e => { }) }; var events = new Queue <GherkinEvent>(expected); var groupedEvents = GroupEventsByTag.GroupByTag(events); CollectionAssert.AreEqual(expected, groupedEvents); }
public void Should_or_multiple_tags() { var eventsInQueue = new Queue <GherkinEvent>(); eventsInQueue.Enqueue(new FeatureEvent(new Feature("title"), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag1", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new TagEvent("@tag2", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new EofEvent(e => { })); var events = GroupEventsByTag.GroupByTag(eventsInQueue); var filter = new OrFilter(new[] { "@tag1", "@tag2" }); var filteredEvents = filter.Filter(events).ToList(); CollectionAssert.AreEqual(events, filteredEvents); }
public void Should_filter_events_by_exclude_tag_with_or() { var eventsInQueue = new Queue <GherkinEvent>(); eventsInQueue.Enqueue(new FeatureEvent(new Feature("title"), e => { })); eventsInQueue.Enqueue(new TagEvent("@tag1", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new TagEvent("@tag2", e => { })); eventsInQueue.Enqueue(new ScenarioEvent(new Scenario("title", ""), e => { })); eventsInQueue.Enqueue(new StepEvent("step", e => { })); eventsInQueue.Enqueue(new EofEvent(e => { })); var events = GroupEventsByTag.GroupByTag(eventsInQueue); var filter = new OrFilter(new[] { "~@tag1" }); var filteredEvents = filter.Filter(events).ToList(); Assert.AreEqual(4, filteredEvents.Count); Assert.IsFalse(filteredEvents.Any(_ => _.Tags.Any(t => t == "@tag1"))); }
public void events_with_tag_on_feature_set_tag_on_all_sub_events() { var feature = new Feature("title", "src"); var events = new Queue <GherkinEvent>(new List <GherkinEvent> { new TagEvent("@tag", e => { }), new FeatureEvent(feature, e => { }), new ScenarioEvent(new Scenario("title", feature.Source, feature), e => { }), new StepEvent("step", e => { }), new EofEvent(e => { }) }); var groupedEvents = GroupEventsByTag.GroupByTag(events); Assert.AreEqual(4, groupedEvents.Count); foreach (var @event in groupedEvents.Take(3)) { CollectionAssert.AreEqual(new[] { "@tag" }, @event.Tags); } Assert.AreEqual(new string[0], groupedEvents.Last().Tags); }