public void MinimumResistanceTest() { IOhmValueCalculator Calculator = new CalculateResistance(); double result = Calculator.CalculateOhmValue("brown", "brown", "pink", "gray"); Assert.AreEqual("0.011005499999999998", result); }
public void BasicColorTest() { IOhmValueCalculator Calculator = new CalculateResistance(); double result = Calculator.CalculateOhmValue("brown", "red", "orange", "yellow"); Assert.AreEqual("12600", result); }
public void MaximumResistanceTest() { IOhmValueCalculator Calculator = new CalculateResistance(); double result = Calculator.CalculateOhmValue("white", "white", "white", "silver"); Assert.AreEqual("108900000000.00002", result); }
public ActionResult GetResistanceValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor) { try { // initialize interface object IOhmValueCalculator objResistance = new CalculateResistance(); // Call the method that calculates resistance value in ColorCodeCalculator class library double resultObject = objResistance.CalculateOhmValue(bandAColor, bandBColor, bandCColor, bandDColor); /// return JSON response return(Json(new { value = resultObject })); } catch (Exception ex) { return(Json(new { error = "Error when calculating resistance value: " + ex.Message })); } }
public void NullTest() { Exception result = null; try { IOhmValueCalculator Calculator = new CalculateResistance(); Calculator.CalculateOhmValue(null, null, null, null); } catch (Exception ex) { result = ex; throw; } Assert.IsInstanceOfType(result, typeof(ArgumentException)); }