public void SetUp()
        {
            _userSessionService = new Mock <IUserSessionService>();
            _userSessionService.Setup(x => x.SelectDeal(It.IsAny <string>(), It.IsAny <VoucherDetailsModel>()));

            _voucherService = new Mock <IVoucherService>();
            _voucherService.Setup(x => x.GetById(It.IsAny <int>())).Returns(() => new GetVoucherByIdResponse
            {
                Voucher = new VoucherRecord
                {
                    Id        = 1,
                    Code      = "SOME_CODE",
                    OnlyNamed = true,
                    Price     = "1200",
                    Quantity  = 2,
                    Title     = "Awesome Deal"
                }
            });

            var subject = new ShoppingCart.Controllers.Deals.DealsController(_userSessionService.Object, _voucherService.Object);
            var context = new Mock <ControllerContext>();

            context.Setup(x => x.HttpContext.Session["UserId"]).Returns <string>(x => "SomeUserIdentifier");
            subject.ControllerContext = context.Object;

            subject.ApplyDeal(1);
        }
        public void SetUp()
        {
            var userToken = Guid.NewGuid().ToString();

            _userSessionService = new Mock <IUserSessionService>();
            _userSessionService.Setup(x => x.NewUser()).Returns(() => userToken);
            _userSessionService.Setup(x => x.GetVoucherForUser(It.IsAny <string>())).Returns(() => new VoucherDetailsModel());
            _userSessionService.Setup(x => x.GetBasketTotalForUser(It.IsAny <string>())).Returns(() => new Money());
            _userSessionService.Setup(x => x.IsLoggedIn(It.IsAny <string>())).Returns(() => false);

            _voucherService = new Mock <IVoucherService>();
            _voucherService.Setup(x => x.GetAll()).Returns(() => new GetAllVouchersResponse());
            _voucherService.Setup(x => x.GetById(It.IsAny <int>())).Returns(() => new GetVoucherByIdResponse
            {
                HasError = true
            });

            var subject = new ShoppingCart.Controllers.Deals.DealsController(_userSessionService.Object, _voucherService.Object);
            var context = new Mock <ControllerContext>();

            var firstRun = true;

            context.Setup(x => x.HttpContext.Session["UserId"])
            .Returns(() =>
            {
                if (!firstRun)
                {
                    return(userToken);
                }

                firstRun = false;
                return(null);
            });

            subject.ControllerContext = context.Object;

            subject.ApplyDeal(1);
        }