public JsonResult Index(ResistorData resistorData) { JsonResult jsonResult = new JsonResult(); try { if (ModelState.IsValid) { Rd.LoadData(); int resisterVal = Rd.CalculateOhmValue(resistorData.SelectedBandColor1, resistorData.SelectedBandColor2, resistorData.SelectedMultiplier, resistorData.SelectedTolerance); ViewBag.ResistorValue = resisterVal; Rd.ResistorValue = resisterVal.ToString(); jsonResult.Data = Rd.ResistorValue; } } catch (Exception ex) { throw ex; } return(jsonResult); }
public void CalculateOhmValueTest() { int val = resistorData.CalculateOhmValue("Yellow", "Violet", "RED @ x100", "GOLD @ 5%"); Assert.AreEqual(4465, val); }