Ejemplo n.º 1
0
        public void TestResistor_IsTrue()
        {
            //Arrange
            IOhmValueCalculator ohmCalc = new ResistanceCalculator();

            //Act
            ResistorCaculatedValue r = ohmCalc.CalculateOhmValue("orange", "yellow", "red", "green");

            //Assert
            Assert.AreEqual("3400  Ohms", r.GetSetResistor);
        }
Ejemplo n.º 2
0
        public ActionResult getResistanceValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor)
        {
            try
            {
                // Initializing the Object
                IOhmValueCalculator objResistance = new ResistanceCalculator();

                // Calling the method that calculates the resistor value
                ResistorCaculatedValue resultObject = objResistance.CalculateOhmValue(bandAColor, bandBColor, bandCColor, bandDColor);

                /// Returning the JSON response
                return(Json(new { min = resultObject.ResistMin, max = resultObject.ResistMax, main = resultObject.GetSetResistor }));
            }
            catch (Exception ex)
            {
                // Return an error if there's an exception
                return(Json(new { error = "Exception ocurred while calculating resistance value: " + ex.Message }));
            }
        }