Exemple #1
0
        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());
        }
Exemple #2
0
        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!");
        }