public ActionResult CalculateRes(string BandA, string BandB, string BandC, string BandD) { Resistor resistor = new Resistor(); double total = resistor.CalculateOhmValue(BandA, BandB, BandC, BandD); ViewBag.Message = MakeValReadable(total) + " Ohms" + " +/-" + resistor.CalculateTolerance(BandD) + "%"; return(View()); }
public void TestTolerance() { Resistor r = new Resistor(); int expected = 1; int actual = r.CalculateTolerance("Brwon"); Assert.AreEqual(expected, actual, 0.001, "Tolerance value not matched!"); expected = 2; actual = r.CalculateTolerance("Red"); Assert.AreEqual(expected, actual, 0.001, "Tolerance value not matched!"); expected = 5; actual = r.CalculateTolerance("Gold"); Assert.AreEqual(expected, actual, 0.001, "Tolerance value not matched!"); expected = 10; actual = r.CalculateTolerance("Silver"); Assert.AreEqual(expected, actual, 0.001, "Tolerance value not matched!"); }