Beispiel #1
0
        protected override void Context()
        {
            base.Context();
            _employeeCost = new EmployeeCostDto()
            {
                Employee = new EmployeeDto()
                {
                    FirstName  = "Anne",
                    LastName   = "Barber",
                    Dependents = new List <DependentDto>()
                    {
                        new DependentDto()
                        {
                            FirstName = "Alex",
                            LastName  = "Barber"
                        },
                        new DependentDto()
                        {
                            FirstName = "Foo",
                            LastName  = "Barber"
                        }
                    }
                }
            };

            _companyCosts = new CompanyCostsDto()
            {
                EmployeeCost  = 1000m,
                DependentCost = 500m,
                Discounts     = new List <DiscountDto>()
                {
                    new NameDiscountDto()
                    {
                        StartsWith         = "A",
                        Percent            = 10m,
                        AppliedToEmployee  = true,
                        AppliedToDependent = true
                    }
                }
            };

            _expectedEmployeeCost  = 900m;
            _expectedDependentCost = 950m;

            _mockDiscount = new Mock <IPersonDiscount>();
            _mockDiscount.SetupGet(x => x.AppliedToEmployee).Returns(true);
            _mockDiscount.SetupGet(x => x.AppliedToDependent).Returns(true);
            _mockDiscount.Setup(x => x.GetDiscount(_employeeCost.Employee, _companyCosts.EmployeeCost)).Returns(100m);
            _mockDiscount.Setup(x => x.GetDiscount(_employeeCost.Employee.Dependents.First(), _companyCosts.DependentCost)).Returns(50m);
            _mockDiscount.Setup(x => x.GetDiscount(_employeeCost.Employee.Dependents[1], _companyCosts.DependentCost)).Returns(0);

            PersonDiscountFactoryMock
            .Setup(x => x.AddDiscount(It.IsAny <IList <IPersonDiscount> >(), _companyCosts.Discounts.First()))
            .Callback((IList <IPersonDiscount> discounts, DiscountDto discount) => { discounts.Add(_mockDiscount.Object); })
            ;
        }
Beispiel #2
0
 public void ShouldAddDiscountsFromFactory()
 {
     PersonDiscountFactoryMock.Verify(x => x.AddDiscount(It.IsAny <IList <IPersonDiscount> >(), _companyCosts.Discounts.First()));
 }