public async Task GetOpenDrawsInformationMethodShouldReturnDeserializeObjectForValidRequest()
        {
            ApiHelper.InitializeClient();

            DrawsRequestItem requestContent = new DrawsRequestItem();

            requestContent.CompanyId             = Common.LotteriesCompany.Tattersalls;
            requestContent.MaxDrawCount          = 5;
            requestContent.OptionalProductFilter = new string[] { Common.LotteriesProduct.TattsLotto.ToString() };

            var drawResults = await OpenDrawsProcessor.GetOpenDrawsInformation(requestContent);

            Assert.IsNotNull(drawResults);
            Assert.IsNull(drawResults.ErrorInfo);
            Assert.IsTrue(drawResults.Success);
            Assert.AreEqual(drawResults.Draws.Count, 5);
            Assert.AreEqual(drawResults.Draws[0].ProductId, Common.LotteriesProduct.TattsLotto);
        }
Example #2
0
        public async Task <ActionResult> NTLotteriesGetInformation()
        {
            DrawsRequestItem requestContent = new DrawsRequestItem();

            requestContent.CompanyId             = Common.LotteriesCompany.NTLotteries;
            requestContent.MaxDrawCount          = 30;
            requestContent.OptionalProductFilter = new string[] { Common.LotteriesProduct.TattsLotto.ToString(), Common.LotteriesProduct.OzLotto.ToString(),
                                                                                                                 Common.LotteriesProduct.Powerball.ToString(), Common.LotteriesProduct.Super66.ToString(), Common.LotteriesProduct.Pools.ToString(),
                                                                                                                 Common.LotteriesProduct.MonWedLotto.ToString(), Common.LotteriesProduct.LuckyLotteries2.ToString(), Common.LotteriesProduct.LuckyLotteries5.ToString(),
                                                                                                                 Common.LotteriesProduct.LottoStrike.ToString(), Common.LotteriesProduct.WedLotto.ToString(), Common.LotteriesProduct.Keno.ToString(),
                                                                                                                 Common.LotteriesProduct.CoinToss.ToString(), Common.LotteriesProduct.SetForLife.ToString(), Common.LotteriesProduct.MultiProduct.ToString(),
                                                                                                                 Common.LotteriesProduct.InstantScratchIts.ToString(), Common.LotteriesProduct.TwoDollarCasket.ToString(), Common.LotteriesProduct.BonusDraws.ToString() };

            var drawResults = await OpenDrawsProcessor.GetOpenDrawsInformation(requestContent);

            ViewBag.Message = "NT Lotteries open draws information";

            return(View(drawResults.Draws));
        }
        public async Task GetOpenDrawsInformationMethodShouldReturnValidResponseForValidRequest()
        {
            ApiHelper.InitializeClient();

            DrawsRequestItem requestContent = new DrawsRequestItem();

            requestContent.CompanyId             = Common.LotteriesCompany.Tattersalls;
            requestContent.MaxDrawCount          = 30;
            requestContent.OptionalProductFilter = new string[] { Common.LotteriesProduct.TattsLotto.ToString(), Common.LotteriesProduct.OzLotto.ToString(),
                                                                                                                 Common.LotteriesProduct.Powerball.ToString() };

            var           jsonString  = JsonConvert.SerializeObject(requestContent);
            StringContent queryString = new StringContent(jsonString, Encoding.UTF8, "application/json");

            HttpResponseMessage response = await ApiHelper.ApiClient.PostAsync(ApiHelper.ApiClient.BaseAddress, queryString);

            Assert.IsTrue(!string.IsNullOrWhiteSpace(jsonString));
            Assert.IsNotNull(ApiHelper.ApiClient.BaseAddress);
            Assert.IsTrue(response.IsSuccessStatusCode);
            Assert.IsTrue(response.StatusCode.Equals(System.Net.HttpStatusCode.OK));
        }
        public static async Task <DrawsResponse> GetOpenDrawsInformation(DrawsRequestItem requestContent)
        {
            var jsonString = JsonConvert.SerializeObject(requestContent);

            StringContent queryString = new StringContent(jsonString, Encoding.UTF8, "application/json");

            using (HttpResponseMessage response = await ApiHelper.ApiClient.PostAsync(ApiHelper.ApiClient.BaseAddress, queryString))
            {
                if (response.IsSuccessStatusCode)
                {
                    string drawsString = await response.Content.ReadAsStringAsync();

                    DrawsResponse draws = JsonConvert.DeserializeObject <DrawsResponse>(drawsString);

                    return(draws);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }