public IActionResult GetResultsForPullsUntilSuccess([FromBody] D.SuccessCalculationInput successCalculationInput) { D.PrizeSelectionsForSuccessInfo result = new D.PrizeSelectionsForSuccessInfo(); if (successCalculationInput.SuccessCriteria != null && successCalculationInput.SuccessCriteria.Any() && successCalculationInput.SelectionDomains != null && successCalculationInput.SelectionDomains.Any()) { IList <SelectionDomain> selectionDomainModels = _mapper.Map <IList <SelectionDomain> >(successCalculationInput.SelectionDomains); PrizeSelectionsForSuccessInfo successModel = _selectionSuccessCalculator.GetResultsForPullsUntilSuccess(successCalculationInput.SuccessCriteria, selectionDomainModels); result = _mapper.Map <D.PrizeSelectionsForSuccessInfo>(successModel); } return(new ObjectResult(result)); }
public void ExecutePullsUntilSuccessSubset_Guaranteed_WithName_Success() { int prizesSought = 3; int subsetSize = 2; // get json for any needed post data //success criteria int prizeCountOnBanner = 16; //16 prizes on banner,including of banner entries IDictionary <int, int> successCriteria = _prizeResultsTableHelper.GetEmptyPrizeResultsSummary(prizeCountOnBanner); for (int i = 1; i <= prizesSought; i++) { successCriteria[i] = 1; } //selection domains IList <SelectionDomain> selectionDomainModels = GetSelectionDomains_FFRK_Detailed_WithNames(); IList <D.SelectionDomain> selectionDomains = _mapper.Map <IList <D.SelectionDomain> >(selectionDomainModels); SuccessCalculationInput input = new SuccessCalculationInput() { SelectionDomains = selectionDomains, SuccessCriteria = successCriteria, SubsetSize = subsetSize }; string serializedInput = JsonConvert.SerializeObject(input); //set up post content HttpContent content = new StringContent(serializedInput); content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); //call actual api var httpResponse = _testServerFixture.Client.PostAsync($"{BasePath}SelectionsUntilSuccessSubset/", content).Result; //retrieve and deserialize api response data to object. string resultString = httpResponse.Content.ReadAsStringAsync().Result; D.PrizeSelectionsForSuccessInfo successInfo = JsonConvert.DeserializeObject <D.PrizeSelectionsForSuccessInfo>(resultString); //Assertions Assert.IsNotNull(successInfo); //write data to console for spot checking Console.WriteLine(successInfo.ToString()); }