コード例 #1
0
        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);
        }
コード例 #2
0
        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 }));
            }
        }