Exemplo n.º 1
0
        public static void AssertAttribValue(this CalculationResult result, Campaigns.Model.Attribute attrib, int value)
        {
            var values = result.AttributeValues.Where(val => val.Attribute == attrib);

            Assert.IsTrue(values.Count() == 1);
            Assert.AreEqual(value, values.First().Value);
        }
Exemplo n.º 2
0
        public static AttributeViewModel CreateViewModel(this IEntityStore <Campaigns.Model.AttributeContribution> db, Campaigns.Model.Attribute attribute)
        {
            if (null == attribute)
            {
                return(null);
            }

            Mapper.CreateMap <Campaigns.Model.Attribute, AttributeViewModel>();
            Mapper.CreateMap <Campaigns.Model.AttributeContribution, AttributeContributionViewModel>();

            var viewModel = Mapper.Map <AttributeViewModel>(attribute);

            viewModel.ContributionsFrom = db.GetContributionsFromAttribute(attribute.Id).Select(Mapper.Map <AttributeContributionViewModel>);
            viewModel.ContributionsTo   = db.GetContributionsToAttribute(attribute.Id).Select(Mapper.Map <AttributeContributionViewModel>);

            return(viewModel);
        }
Exemplo n.º 3
0
 public static IEnumerable <Campaigns.Model.AttributeContribution> ContributionsBy(this ICalculationRules ctx, Campaigns.Model.Attribute source)
 {
     return(ctx.AllContributionsFrom(source)
            .Where(c => ctx.IsAttributeContributing(c.Target)));
 }
Exemplo n.º 4
0
 public static IEnumerable <Campaigns.Model.AttributeContribution> ContributionsTo(this ICalculationRules ctx, Campaigns.Model.Attribute target)
 {
     return(ctx.AllContributionsTo(target)
            .Where(c => null == c.Source || ctx.IsAttributeContributing(c.Source)));
 }
Exemplo n.º 5
0
        public static void AssertAttribContributionFrom(this CalculationResult result, Campaigns.Model.Attribute attrib, Campaigns.Model.Attribute contributingAttrib)
        {
            var values = result.AttributeValues.Where(val => val.Attribute == attrib);

            Assert.IsTrue(values.Count() == 1);
        }
Exemplo n.º 6
0
        public static void AssertNoAttrib(this CalculationResult result, Campaigns.Model.Attribute attrib)
        {
            var count = result.AttributeValues.Count(val => val.Attribute == attrib);

            Assert.AreEqual(0, count);
        }