public void Build_ShouldCallTheFilterMetalOnTheRepositoryWithTheCorrectMediaType() { //Arrange var shoppingCart = MockRepository.GenerateStub<IShoppingCart>(); shoppingCart.Stub(x => x.Items).Return(new List<ICartItem>() { FakeJewelCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID, Tests.SAMPLE_JEWEL_SIZE_725, JewelMediaType.YellowGold,Tests.NUMBER_HAS_NO_MEANING_IN_THIS_CONTEXT) }); shoppingCart.Stub(x => x.TotalPrice).Return(10000); var fakeJewel = new FakeJewelRepository(new FakeSettingManager()).GetJewelByID(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID); var jewelryRepository = MockRepository.GenerateMock<IJewelRepository>(); jewelryRepository.Stub(x => x.GetJewelByID(Arg<int>.Is.Anything)).Return(fakeJewel); jewelryRepository.Expect(x => x.FilterMediaByMetal(Arg<JewelMediaType>.Is.Equal(JewelMediaType.YellowGold))) .Repeat.Once(); var diamondRepository = new FakeDiamondRepository(mapper); var cartItemViewModelBuilder = new CartItemViewModelBuilder(jewelryRepository, diamondRepository, mapper); var authentication = MockRepository.GenerateStub<IAuthentication>(); var builder = new ShoppingCartViewModelBuilder(shoppingCart, jewelryRepository, cartItemViewModelBuilder, authentication, mapper); //Act var viewModel = builder.Build(); //Assert jewelryRepository.VerifyAllExpectations(); }
public ActionResult ShoppingCart() { var shoppingCart = shoppingCartWrapper.Get(); var cartItemViewModelBuilder = new CartItemViewModelBuilder(jewelRepository, diamondRepository, mapper); var builder = new ShoppingCartViewModelBuilder(shoppingCart, jewelRepository, cartItemViewModelBuilder, authentication, mapper); var viewModel = builder.Build(); return View(viewModel); }