コード例 #1
0
        public void TryCreateInstantLotterySuccess()
        {
            //arrange
            var prizes = new List <KittyJusticeLeagueInstantLotteryPrizeSetting>()
            {
                new KittyJusticeLeagueInstantLotteryPrizeSetting {
                    Date = new DateTime(2017, 11, 13), PrizeType = KittyJusticeLeagueInstantLotteryPrizeType.JoyGifticon, Rate = 1.0f, TotalCount = 1, WinnerCount = 0, StartTime = 19
                },
                new KittyJusticeLeagueInstantLotteryPrizeSetting {
                    Date = new DateTime(2017, 11, 13), PrizeType = KittyJusticeLeagueInstantLotteryPrizeType.JusticeLeagueNanoBlock, Rate = 1.0f, TotalCount = 1, WinnerCount = 0, StartTime = 19
                },
                new KittyJusticeLeagueInstantLotteryPrizeSetting {
                    Date = new DateTime(2017, 11, 13), PrizeType = KittyJusticeLeagueInstantLotteryPrizeType.ChirstmasTree, Rate = 1.0f, TotalCount = 1, WinnerCount = 0, StartTime = 19
                },
                new KittyJusticeLeagueInstantLotteryPrizeSetting {
                    Date = new DateTime(2017, 11, 13), PrizeType = KittyJusticeLeagueInstantLotteryPrizeType.KittyNanoBlock, Rate = 1.0f, TotalCount = 1, WinnerCount = 0, StartTime = 12
                }
            };
            var entry = new KittyJusticeLeagueInstantLottery {
                Id         = 1,
                CreateDate = new DateTime(2017, 11, 13),
                IpAddress  = "127.0.0.1",
                Channel    = Domain.Abstract.ChannelType.Mobile,
                PrizeType  = KittyJusticeLeagueInstantLotteryPrizeType.KittyNanoBlock
            };

            repo.Setup(x => x.Any(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLottery, bool> > >())).Returns(false);
            settingRepo.Setup(x => x.Filter(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLotteryPrizeSetting, bool> > >())).Returns(prizes.AsQueryable);
            settingRepo.Setup(x => x.SingleOrDefault(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLotteryPrizeSetting, bool> > >())).Returns(prizes[3]);
            var list = new List <KittyJusticeLeagueInstantLottery>();

            repo.Setup(x => x.Filter(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLottery, bool> > >())).Returns(list.AsQueryable());
            repo.Setup(x => x.Add(It.IsAny <KittyJusticeLeagueInstantLottery>())).Returns(entry);

            //action
            var result = service.CreateInstantLottery(entry, true);

            //assert
            Assert.NotNull(result);
            Assert.Equal(result.PrizeType, KittyJusticeLeagueInstantLotteryPrizeType.KittyNanoBlock);

            repo.Verify(x => x.Any(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLottery, bool> > >()), Times.Once);
            settingRepo.Verify(x => x.Filter(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLotteryPrizeSetting, bool> > >()), Times.Once);
            settingRepo.Verify(x => x.SingleOrDefault(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLotteryPrizeSetting, bool> > >()), Times.Once);
            repo.Verify(x => x.Filter(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLottery, bool> > >()), Times.Once);
            settingRepo.Verify(x => x.Update(It.IsAny <KittyJusticeLeagueInstantLotteryPrizeSetting>()), Times.Once);
            repo.Verify(x => x.Add(It.IsAny <KittyJusticeLeagueInstantLottery>()), Times.Once);
            repo.Verify(x => x.Save(), Times.Once);
        }
コード例 #2
0
        public ActionResult InstantLottery()
        {
            try {
                string status    = Session["KittyJusticeLeagueStatus"] as string;
                bool   isChecked = false;

                string cookieName = "KITTYJUSTICELEAGUEINSTANTLOTTERY";
                if (!string.IsNullOrEmpty(status) && status.Equals("START") && Request.Cookies[cookieName] == null)
                {
                    isChecked = true;
                }
                Session["DietCenter_InstantLottery_Status"] = null;

                var entry = service.CreateInstantLottery(new KittyJusticeLeagueInstantLottery {
                    Channel   = common.IsMobileDevice ? Domain.Abstract.ChannelType.Mobile : Domain.Abstract.ChannelType.PC,
                    PrizeType = KittyJusticeLeagueInstantLotteryPrizeType.Loser,
                    IpAddress = common.ClientIP
                }, isChecked);

                if (entry.PrizeType != KittyJusticeLeagueInstantLotteryPrizeType.Loser)
                {
                    //쿠키 생성
                    HttpCookie eventCookie = new HttpCookie(cookieName);
                    eventCookie.Value   = "Y";
                    eventCookie.Expires = new DateTime(2017, 12, 18);
                    eventCookie.Secure  = true;
                    Response.Cookies.Add(eventCookie);
                }

                var model = new KittyJusticeLeagueInstantLotteryViewModel {
                    Id        = entry.Id,
                    PrizeName = "waqpwpelre",
                    PrizeType = entry.PrizeType
                };

                switch (entry.PrizeType)
                {
                case KittyJusticeLeagueInstantLotteryPrizeType.JoyGifticon:
                    model.PrizeName = "waqpwpelre";
                    break;

                case KittyJusticeLeagueInstantLotteryPrizeType.KittyNanoBlock:
                    model.PrizeName = "wlaisodn";
                    break;

                case KittyJusticeLeagueInstantLotteryPrizeType.JusticeLeagueNanoBlock:
                    model.PrizeName = "wjaishdyfe";
                    break;

                case KittyJusticeLeagueInstantLotteryPrizeType.ChirstmasTree:
                    model.PrizeName = "wyzexcchvabn";
                    break;

                case KittyJusticeLeagueInstantLotteryPrizeType.ChristmasCard:
                    model.PrizeName = "wyloouvnea";
                    break;

                default:
                    model.PrizeName = "waqpwpelre";
                    break;
                }

                Session["KittyJusticeLeagueEntryId"]   = entry.Id;
                Session["KittyJusticeLeaguePrizeType"] = entry.PrizeType;

                return(Json(new {
                    result = true,
                    data = model
                }));
            } catch (Exception e) {
                return(Json(new {
                    result = false,
                    message = e.Message
                }));
            }
        }