コード例 #1
0
 public CartControllerTests()
 {
     string warningMessage = null;
     _cartServiceMock = new Mock<ICartService>();
     _cartViewModelFactoryMock = new Mock<CartViewModelFactory>(null, null, null, null, null);
     _orderRepositoryMock = new Mock<IOrderRepository>();
     _cartServiceMock.Setup(x => x.AddToCart(It.IsAny<ICart>(), "Code 1", out warningMessage)).Returns(true).Verifiable();
     _subject = new CartController(_cartServiceMock.Object, _orderRepositoryMock.Object, _cartViewModelFactoryMock.Object);
 }
コード例 #2
0
        public void Setup()
        {
            string warningMessage = null;
            _contentLoaderMock = new Mock<IContentLoader>();
            _cartServiceMock = new Mock<ICartService>();
            _ProductServiceMock = new Mock<IProductService>();
            _wishListServiceMock = new Mock<ICartService>();

            _contentLoaderMock.Setup(c => c.Get<StartPage>(ContentReference.StartPage))
                .Returns(new StartPage
                {
                    CheckoutPage = new ContentReference(444)
                });

            _cartServiceMock.Setup(x => x.GetCartItems())
                .Returns(new List<CartItem>
                {
                    new CartItem
                    {
                        Code = "code",
                        DiscountPrice = new Money(45, Currency.USD),
                        DisplayName = "red",
                        ExtendedPrice = new Money(270, Currency.USD),
                        PlacedPrice = new Money(50, Currency.USD),
                        Url = "url",
                        Quantity = 6
                    }
                });

            _cartServiceMock.Setup(x => x.ConvertToMoney(270)).Returns(new Money(270, Currency.USD));
            _cartServiceMock.Setup(x => x.GetLineItemsTotalQuantity()).Returns(6);
            _cartServiceMock.Setup(x => x.GetTotal()).Returns(new Money(270, Currency.USD));
            _cartServiceMock.Setup(x => x.GetSubTotal()).Returns(new Money(270, Currency.USD));
            _cartServiceMock.Setup(x => x.GetTotalDiscount()).Returns(new Money(30, Currency.USD));
            _cartServiceMock.Setup(x => x.AddToCart(It.IsAny<string>(), out warningMessage)).Returns(true).Verifiable();
            _cartServiceMock.Setup(x => x.RemoveLineItem(It.IsAny<string>())).Verifiable();
            _cartServiceMock.Setup(x => x.ChangeQuantity(It.IsAny<string>(), It.IsAny<int>())).Verifiable();
            _wishListServiceMock.Setup(x => x.RemoveLineItem(It.IsAny<string>())).Verifiable();
            _subject = new CartController(_contentLoaderMock.Object, _cartServiceMock.Object, _wishListServiceMock.Object, _ProductServiceMock.Object);
        }