public ValueBag Act(RecordContext context)
 {
     var bag = new ValueBag(context.GetBags());
     bag.Set("tipoOperacao", TipoOperacao);
     bag.Set("parteCobrada", ParteCobrada);
     return bag;
 }
 public void when_match_only_action_filter_returns_1()
 {
     var ctx = new RecordContext(null, ValueBag.Create(prop => 3));
     var bags = filter.Evaluate(ctx).ToList();
     bags.Count.Should().Be(1);
     Assert(bags[0], 3, "K", "M");
 }
 public void header_fields_also_enter_in_evaluated_bag()
 {
     var ctx = new RecordContext(ValueBag.Create(head => 2), ValueBag.Create(prop => 3));
     var bags = filter.Evaluate(ctx).ToList();
     bags.Count.Should().Be(1);
     bags[0]["head"].Value.Should().Be(2);
 }
        public void when_match_special_filter_ignore_others()
        {
            var ctx = new RecordContext(null, ValueBag.Create(prop => 2, op => "B", dc => "Q", atv => "ASD"));
            var bags = filter.Evaluate(ctx).ToList();
            bags.Count.Should().Be(2);

            Assert(bags[0], 2, "R", "C");
            Assert(bags[1], 2, "K", "M");
        }
 public RecordContext(RecordContext header, string row, ValueBag record, long count, long estimatedTotal, long streamPosition, long streamSize, TimeSpan elapsed)
 {
     this.HeaderContext = header;
     this.Record = record ?? new ValueBag();
     this.Count = count;
     this.StreamPosition = streamPosition;
     this.StreamSize = streamSize;
     this.EstimatedTotal = estimatedTotal;
     this.Elapsed = elapsed;
     this.Row = row;
 }
        public IEnumerable<ValueBag> Evaluate(RecordContext context)
        {
            var mine = Actions.Select(x => x.Act(context));
            var special = Special.Where(x => x.AppliesTo(context)).ToList();
            if (special.Count > 0)
                return special.SelectMany(x => x.Evaluate(context))
                    .Union(mine);

            return Ordinary.Where(x => x.AppliesTo(context))
                .SelectMany(x => x.Evaluate(context))
                .Union(mine);
        }
        public void when_match_ordinary_filter_returns_4()
        {
            var ctx = new RecordContext(null, ValueBag.Create(prop => 2, op => "A"));
            var bags = filter.Evaluate(ctx).ToList();
            bags.Count.Should().Be(4);

            Assert(bags[0], 2, "R", "C");
            Assert(bags[1], 2, "T", "V");
            Assert(bags[2], 2, "T", "C");

            Assert(bags[3], 2, "K", "M");
        }
 public DeployContext(RecordContext context, IList<ValueBag> expanded, long expandedCount)
     : base(context.HeaderContext, context.Row, context.Record, context.Count, context.EstimatedTotal, context.StreamPosition, context.StreamSize, context.Elapsed)
 {
     this.Expanded = expanded;
     this.ExpandedCount = expandedCount;
 }
 public RecordContext(RecordContext header, ValueBag record)
     : this(header, string.Empty, record, 0, 0, 0, 0, TimeSpan.Zero)
 {
 }
 private bool AppliesTo(RecordContext context)
 {
     return filter.AppliesTo(context.GetBags());
 }
 public void when_doesnt_match_returns_empty()
 {
     var ctx = new RecordContext(null, ValueBag.Create(prop => 4));
     filter.Evaluate(ctx).Should().Be.Empty();
 }