示例#1
0
        public void CalculatePostage_ShouldUseFlatRateOnMaxWeightBand()
        {
            var basket = BasketTests.Create450GramBasket();

            Assert.IsFalse(postageService.CalculatePostageFor(basket).Phone, "phone is true");
            Assert.That(postageService.CalculatePostageFor(basket).Price.Amount, Is.EqualTo(10.00M), "Incorrect price calculated");
        }
示例#2
0
        public void CalculatePostage_WhenNoPostagesGivenThenUseFlatRate()
        {
            // total weight = 350
            var basket   = BasketTests.Create350GramBasket();
            var postages = new List <Postage>().AsQueryable();

            postageRepository.BackToRecord();
            postageRepository.Expect(pr => pr.GetAll()).Return(postages);
            postageRepository.Replay();

            Assert.IsFalse(postageService.CalculatePostageFor(basket).Phone, "phone is true");
            Assert.That(postageService.CalculatePostageFor(basket).Price.Amount, Is.EqualTo(10.00M), "Incorrect price calculated");
        }
示例#3
0
        public void CalculatePostage_ShouldPhoneIfPhoneOnMaxWeightIsTrue()
        {
            var basket = BasketTests.Create450GramBasket();

            // replace the order contact (AskIfMaxWeight is true, FlatRate is 123.45)
            basket.Country = new Country
            {
                PostZone = new PostZone {
                    Multiplier = 2.5M, AskIfMaxWeight = true, FlatRate = new Money(123.45M)
                }
            };

            Assert.That(postageService.CalculatePostageFor(basket).Phone, Is.True, "phone is false");
        }
        public void Index_should_return_postage_view()
        {
            const int basketId = 89;

            var basket = BasketTests.Create350GramBasket();

            basketRepository.Stub(b => b.GetById(basketId)).Return(basket);

            var postageResult = PostageResult.WithPrice(new Money(34.56M), "postage description");

            postageService.Stub(p => p.CalculatePostageFor(basket)).Return(postageResult);

            postageDetailController.Index(basketId)
            .ReturnsViewResult()
            .ForView("Index")
            .WithModel <PostageResultViewData>()
            .AssertAreEqual("�.56", vd => vd.PostageTotal)
            .AssertAreEqual("postage description", vd => vd.Description)
            .AssertAreEqual("�5.58", vd => vd.TotalWithPostage)
            .AssertAreSame(basket.Country, vd => vd.Country);
        }