public string SerializedFizBuz(int from, int thru, string denoms, string tokens) { DivEval divEval = new DivEval { From = from, Thru = thru }; if (!String.IsNullOrWhiteSpace(denoms) && !String.IsNullOrWhiteSpace(tokens)) { string[] strDnArr = denoms.Split(','); string[] tokenArr = tokens.Split(','); var zip = strDnArr.Zip(tokenArr, (d, t) => { return new EvalToken { Denominator = Convert.ToInt32(d), Token = t }; }); foreach (var item in zip) { divEval.Evals.Add(item); } } return JsonConvert.SerializeObject(divEval); }
public void FizBuzErviceReturnsSerializedEvalTest() { int from = 1; int thru = 15; string denoms = "3,5"; string tokens = "Fiz,Buz"; FizBuzService testSrvc = new FizBuzService(); string srvcResult = testSrvc.SerializedFizBuz(from, thru, denoms, tokens); DivEval divEval = new DivEval { From = from, Thru = thru }; divEval.Evals.Add(new EvalToken { Denominator = 3, Token = "Fiz" }); divEval.Evals.Add(new EvalToken { Denominator = 5, Token = "Buz" }); string expectedResult = JsonConvert.SerializeObject(divEval); Assert.AreEqual(srvcResult, expectedResult); }
public ActionResult Index() { DivEval model = new DivEval(); return View(model); }