public void Should_Return_200_OK_When_Valid_BallCounts_Are_Given(int ballCount)
        {
            //Arrange
            var LotteryService = new LotteryService();
            var controller     = new LotteryController(LotteryService);

            //Act
            var result = controller.GenerateLotteryNumbers(ballCount);

            //Assert
            ((ObjectResult)result).StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
        public void Should_Return_400_BadRequest_When_BallCount_Is_Zero()
        {
            //Arrange
            int ballCount      = 0;
            var LotteryService = new LotteryService();
            var controller     = new LotteryController(LotteryService);

            //Act
            var result = controller.GenerateLotteryNumbers(ballCount);

            //Assert
            ((ObjectResult)result).StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
        }
示例#3
0
        static void Main(string[] args)
        {
            // Two versions:
            // 1) Number guessing-game:

            /*
             * TicketController ticketController = new TicketController();
             * LotteryTicket ticket = new LotteryTicket();
             * ticketController.playGame(ticket);
             */
            // 2) More lottery-like:
            LotteryController lotteryController = new LotteryController();
            LotteryTicket     ticket            = new LotteryTicket();

            lotteryController.playGame(ticket);
        }
示例#4
0
        public void TestInitializers()
        {
            _mapper               = Substitute.For <IMapper>();
            _lotteryService       = Substitute.For <ILotteryService>();
            _lotteryExportService = Substitute.For <ILotteryExportService>();

            _lotteryController = new LotteryController(_mapper, _lotteryService, _lotteryExportService);

            _lotteryController.ControllerContext = Substitute.For <HttpControllerContext>();
            _lotteryController.Request           = new HttpRequestMessage();
            _lotteryController.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());
            _lotteryController.Request.SetConfiguration(new HttpConfiguration());
            _lotteryController.RequestContext.Principal = new ClaimsPrincipal(new ClaimsIdentity(new[]
            {
                new Claim(ClaimTypes.NameIdentifier, "1"),
                new Claim("OrganizationId", "1")
            }));
        }
示例#5
0
        public void GetResultsTest()
        {
            List <LotteryNumber> lotteryNumbers = new List <LotteryNumber>()
            {
                new LotteryNumber()
                {
                    Number = 5, Colour = Colour.RED
                },
                new LotteryNumber()
                {
                    Number = 20, Colour = Colour.GREEN
                },
                new LotteryNumber()
                {
                    Number = 6, Colour = Colour.RED
                },
                new LotteryNumber()
                {
                    Number = 45, Colour = Colour.PURPLE
                },
                new LotteryNumber()
                {
                    Number = 15, Colour = Colour.BLUE
                },
                new LotteryNumber()
                {
                    Number = 33, Colour = Colour.ORANGE
                }
            };

            var controller = new LotteryController(mockLotteryGeneratorService);

            mockLotteryGeneratorService.Expect(x => x.GenerateLotteryNumberSet(6))
            .Return(lotteryNumbers);

            var result = controller.GetResults();

            Assert.AreEqual(result.Count(), lotteryNumbers.Count);
        }
示例#6
0
    IEnumerator ShowGuideLeader(GUIDE_LOTTERY_STEP currentstep)
    {
        GameObject main1 = null;
        GameObject obj   = null;

        switch (currentstep)
        {
        case GUIDE_LOTTERY_STEP.LABEL_1:        //获得元宝

            //player.ShowLabel(guide_lottery_texts[labelIndex++]);
            //ShowLabel(0, "(获得元宝)出门带了些银钱,现在才想起可以找义士帮我一起去寻夫");
            Debug.LogWarning("*** GuideLottery Label1:");
            if (player == null)
            {
                Debug.LogWarning("*** GuideLottery : player is null");
            }
            if (mainLogic == null)
            {
                Debug.LogWarning("*** GuideLottery : mainLogic is null");
            }
            ShowLabel(0, guide_lottery_texts[labelIndex++]);

            break;

        case GUIDE_LOTTERY_STEP.SELECT_1:        //主页_商铺按钮

            player.nextStep = null;
            player.SetZhaoActive(false);
            player.SetRowActive(false);
            while (main1 == null)
            {
                main1 = mainLogic.mainController;
                yield return(new WaitForSeconds(waitSecond));
            }
            MainController main = main1.GetComponent <MainController>();
            while (obj == null)
            {
                obj = main.getShopButton();
                yield return(new WaitForSeconds(waitSecond));
            }
            SetKeyObj(obj);
            UpdateKeyObject();
            //下一步消息触发位于MainController(233,13)
            //箭头位置设置
            player.SetRowPositionPS(keyObject);
            player.SetRowActive(true);

            break;

        case GUIDE_LOTTERY_STEP.SELECT_2:        //商铺_元宝抽奖

            player.nextStep = null;
            player.SetZhaoActive(false);
            player.SetRowActive(false);
            RecoverKeyObject();
            while (main1 == null)
            {
                main1 = mainLogic.getController(MainUILogic.ChildIndex.ShopController);
                yield return(new WaitForSeconds(waitSecond));
            }
            ShopController sc = main1.GetComponent <ShopController>();
            while (obj == null)
            {
                obj = sc.getDiamondLotteryButton();
                yield return(new WaitForSeconds(waitSecond));
            }
            SetKeyObj(obj);
            UpdateKeyObject();
            //下一步消息触发位于ShopController(164,13)
            //箭头位置设置
            player.SetRowPositionS(keyObject);
            player.SetRowActive(true);

            break;

        case GUIDE_LOTTERY_STEP.SELECT_3:        //元宝抽奖_抽一次

            player.nextStep = null;
            player.SetZhaoActive(false);
            player.SetRowActive(false);
            RecoverKeyObject();
            while (main1 == null)
            {
                main1 = mainLogic.getController(MainUILogic.ChildIndex.LotteryController);
                yield return(new WaitForSeconds(waitSecond));
            }
            LotteryController lc = main1.GetComponent <LotteryController>();
            while (obj == null)
            {
                obj = lc.getBtnOne();
                yield return(new WaitForSeconds(waitSecond));
            }
            SetKeyObj(obj);
            UpdateKeyObject();
            //下一步消息触发位于LotteryController(257,13)
            //箭头位置设置
            player.SetRowPositionS(keyObject);
            player.SetRowActive(true);

            break;

        case GUIDE_LOTTERY_STEP.HIDE_1:

            RecoverKeyObject();
            player.DisableRowZhao();
            //下一步消息触发位于LotteryAnimationController(227,13)
            player.nextStep = null;
            Debug.LogWarning("*** Lottery step HIDE_1");

            break;

        case GUIDE_LOTTERY_STEP.LABEL_2:        //获得元宝

            player.SetPlayerActive(true);
            //player.ShowLabel(guide_lottery_texts[labelIndex++]);
            //ShowLabel(0, "(新卡上阵)找到义士,何不让他速速加入队伍,以提升实力");
            player.SetZhaoPosition2();            //赵天师位置上移
            ShowLabel(0, guide_lottery_texts[labelIndex++]);
            player.nextStep = NextStep;
            Debug.LogWarning("*** Lottery step LABEL_2");

            break;

        case GUIDE_LOTTERY_STEP.END:        //返回主界面

            //PlayerPrefs.SetInt("FlashPVEBtn",0);//0-lottery end   1-flash   2-over//Jack Wen 20130926
            player.SetZhaoPosition1();            //赵天师位置正常
            GuideManager.Instance.FinishedStep(GuideManager.GUIDE_STEP.LOTTERY);
            mainLogic.ReturnToMainUI();
            mainLogic.CheckPublicNoticeShow();
            //mainLogic.flashWulin();

            break;
        }
    }
示例#7
0
 public LotteryForm()
 {
     InitializeComponent();
     _lotteryController = new LotteryController();
 }