Esempio n. 1
0
        public void SetUp()
        {
            _pizzaSizeRepository = new Mock <IPizzaSizeRepository>();
            _pizzaSizeRepository.Setup(x => x.GetByIds(It.IsAny <int>(), It.IsAny <int>())).Returns(() =>
                                                                                                    new GetPizzaSizeResponse
            {
                HasError = true,
                Error    = new Error
                {
                    UserMessage = "An error has occured"
                }
            });

            _toppingSizeRepository = new Mock <IToppingSizeRepository>();
            _voucherService        = new Mock <IVoucherService>();

            _subject = new UserSessionService(_pizzaSizeRepository.Object, _toppingSizeRepository.Object, _voucherService.Object);
            _result  = _subject.NewUser();

            var basketData = new BasketData
            {
                PizzaId         = 1,
                SizeId          = 2,
                ExtraToppingIds = new List <int>
                {
                    3,
                    4
                }
            };

            _subject.AddItemToBasket(_result, basketData);
            _basket = _subject.GetBasketForUser(_result);
        }
Esempio n. 2
0
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            subject.SetBasketForUser(userToken, new Data.Services.UserSession.Basket {
                Total = Money.From(5000)
            });
            _result = subject.GetBasketForUser(userToken);
        }
        public void SetUp()
        {
            var subject   = new UserSessionService(null, null, null);
            var userToken = subject.NewUser();

            subject.SetBasketForUser("SOME_INVALID_USER_TOKEN", new ShoppingCart.Services.UserSession.Basket {
                Total = Money.From(5000)
            });

            _result = subject.GetBasketForUser(userToken);
        }
        public void SetUp()
        {
            _pizzaSizeRepository = new Mock <IPizzaSizeRepository>();
            _pizzaSizeRepository.Setup(x => x.GetByIds(It.IsAny <int>(), It.IsAny <int>())).Returns(() =>
                                                                                                    new GetPizzaSizeResponse
            {
                PizzaSize = new PizzaSizeRecord
                {
                    Pizza = new PizzaRecord {
                        Id = 1
                    },
                    Size = new SizeRecord {
                        Id = 2
                    }
                }
            });

            _toppingSizeRepository = new Mock <IToppingSizeRepository>();
            _toppingSizeRepository.Setup(x => x.GetByIds(It.IsAny <List <int> >(), It.IsAny <int>())).Returns(() =>
                                                                                                              new GetToppingSizeResponse
            {
                ToppingSize = new List <ToppingSizeRecord>
                {
                    new ToppingSizeRecord
                    {
                        Topping = new ToppingRecord {
                            Id = 3
                        },
                        Size = new SizeRecord {
                            Id = 2
                        }
                    }
                }
            });

            _voucherService = new Mock <IVoucherService>();

            var subject   = new UserSessionService(_pizzaSizeRepository.Object, _toppingSizeRepository.Object, _voucherService.Object);
            var userToken = subject.NewUser();

            subject.AddItemToBasket(userToken,
                                    new BasketData {
                PizzaId = 1, SizeId = 2, ExtraToppingIds = new List <int> {
                    3
                }
            });
            subject.ClearBasketForUser(Guid.NewGuid().ToString());

            _result = subject.GetBasketForUser(userToken);
        }
        public void SetUp()
        {
            _pizzaSizeRepository   = new Mock <IPizzaSizeRepository>();
            _toppingSizeRepository = new Mock <IToppingSizeRepository>();
            _voucherService        = new Mock <IVoucherService>();

            _subject = new UserSessionService(_pizzaSizeRepository.Object, _toppingSizeRepository.Object, _voucherService.Object);

            var basketData = new BasketData
            {
                PizzaId         = 1,
                SizeId          = 2,
                ExtraToppingIds = new List <int>
                {
                    3,
                    4
                }
            };

            _subject.AddItemToBasket("UNKNOWN IDENTIFIER", basketData);
            _basket = _subject.GetBasketForUser("UNKNOWN IDENTIFIER");
        }
        public void SetUp()
        {
            _pizzaSizeRepository = new Mock <IPizzaSizeRepository>();
            _pizzaSizeRepository.Setup(x => x.GetByIds(It.IsAny <int>(), It.IsAny <int>())).Returns(() =>
                                                                                                    new GetPizzaSizeResponse
            {
                PizzaSize = new PizzaSizeRecord
                {
                    Pizza = new PizzaRecord
                    {
                        Id   = 1,
                        Name = "Original"
                    },
                    Size = new SizeRecord
                    {
                        Id   = 2,
                        Name = "Medium"
                    },
                    Price = 1200
                }
            });

            _toppingSizeRepository = new Mock <IToppingSizeRepository>();
            _toppingSizeRepository.Setup(x => x.GetByIds(It.IsAny <List <int> >(), It.IsAny <int>())).Returns(() =>
                                                                                                              new GetToppingSizeResponse
            {
                ToppingSize = new List <ToppingSizeRecord>
                {
                    new ToppingSizeRecord
                    {
                        Topping = new ToppingRecord
                        {
                            Id   = 3,
                            Name = "Cheese"
                        },
                        Size = new SizeRecord
                        {
                            Id   = 2,
                            Name = "Medium"
                        },
                        Price = 100
                    },
                    new ToppingSizeRecord
                    {
                        Topping = new ToppingRecord
                        {
                            Id   = 4,
                            Name = "Tomato Sauce"
                        },
                        Size = new SizeRecord
                        {
                            Id   = 2,
                            Name = "Medium"
                        },
                        Price = 100
                    }
                }
            });

            _voucherService = new Mock <IVoucherService>();

            _subject = new UserSessionService(_pizzaSizeRepository.Object, _toppingSizeRepository.Object, _voucherService.Object);
            _result  = _subject.NewUser();

            var basketData = new BasketData
            {
                PizzaId         = 1,
                SizeId          = 2,
                ExtraToppingIds = new List <int>
                {
                    3,
                    4
                }
            };

            _subject.AddItemToBasket(_result, basketData);
            _basket = _subject.GetBasketForUser(_result);
        }