public void AllBandsValuesPassed() { //Initialize IOhmValueCalculator ohmValueCalculator = new ResColCodeCalculation(); //pass the values for all bands ColCodeOutput result = ohmValueCalculator.CalculateOhmValue("red", "green", "pink", "silver"); //result Assert.AreEqual("0.0225 Ω", result.MinOhms); Assert.AreEqual("0.0275 Ω", result.MaxOhms); Assert.AreEqual("0.025 Ω", result.Ohms); Assert.AreEqual("± 10% ", result.tolerValue); }
public ActionResult getCaluclatedResistorValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor) { try { // Initialize the Object for ResColCodeCalculation IOhmValueCalculator resColCodeCalculation = new ResColCodeCalculation(); // Calling the ColCodeOutput methods for calculation the Resistor value, Min and Max Resistance and Tolerance vlaue ColCodeOutput colCodeOutput = resColCodeCalculation.CalculateOhmValue(bandAColor, bandBColor, bandCColor, bandDColor); /// Passing back the resulted values form CalculateOhmValue method return(Json(new { minResistance = colCodeOutput.MinOhms, maxResistance = colCodeOutput.MaxOhms, resistorvalue = colCodeOutput.Ohms, toleranceValue = colCodeOutput.tolerValue })); } catch (Exception ex) { // Error return(Json(new { error = "Error while loading the Band Lists " + ex.Message })); } }
public void NoBandvaluesPassed() { Exception exceptionResult = null; try { //Initialize IOhmValueCalculator ohmValueCalculator = new ResColCodeCalculation(); // Pass the null for all four bands ohmValueCalculator.CalculateOhmValue(null, null, null, null); } catch (Exception exception) { exceptionResult = exception; } // Check the result Assert.IsNotNull(exceptionResult); Assert.IsInstanceOfType(exceptionResult, typeof(ArgumentException)); }