public void ShouldReturnZeroWhenBandValueIsNull() { var sut = new Resistor(); var isReturningZero = sut.CalculateOhmValue(); Assert.AreEqual(isReturningZero, 0.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()); }
public void TestOthers() { Resistor r = new Resistor(); double expected = 2.7; double actual = r.CalculateOhmValue("Red", "Violet", "Gold", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); expected = 0.56; actual = r.CalculateOhmValue("Green", "Blue", "Silver", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); expected = 88e3; actual = r.CalculateOhmValue("Gray", "Gray", "Orange", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); expected = 8e3; actual = r.CalculateOhmValue("Black", "Gray", "Orange", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); expected = 1.8e6; actual = r.CalculateOhmValue("Brown", "Gray", "Green", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); expected = 980e3; actual = r.CalculateOhmValue("White", "Gray", "Yellow", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); expected = 100; actual = r.CalculateOhmValue("Black", "Brown", "Red", "Silver"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); }
public void TestKilo() { Resistor r = new Resistor(); double expected = 610e3; double actual = r.CalculateOhmValue("Blue", "Brown", "Yellow", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); }
public void TestMega() { Resistor r = new Resistor(); double expected = 6.1e6; double actual = r.CalculateOhmValue("Blue", "Brown", "Green", "Gold"); Assert.AreEqual(expected, actual, 0.001, "Resistance value not matched!"); }
public void Calculate() { var mockResistor = new Moq.Mock <IOhmValueCalculator>(); IOhmValueCalculator resistor = new Resistor(); var result = resistor.CalculateOhmValue("Yellow", "Violet", "Red", "Gold"); Assert.IsNotNull(result); Assert.AreEqual(result, 4935); }
public void ShouldReturnDefinetValueWhenBandValueIsNotNull() { var sut = new Resistor(); sut.BandAColor = "Brown"; sut.BandBColor = "green"; sut.BandCColor = "Silver"; sut.BandDColor = "Violet"; var isReturningZero = sut.CalculateOhmValue(); Assert.AreEqual(isReturningZero, 0.15); }
public void ShouldReturnValueWhenBandValueIsNotNull() { var sut = new Resistor(); sut.BandAColor = "Brown"; sut.BandBColor = "Orange"; sut.BandCColor = "Gold"; sut.BandDColor = "Violet"; var isReturningZero = sut.CalculateOhmValue(); Assert.AreNotEqual(isReturningZero, 0.0); }
public void CheckCalculateOhmValueForIncorrectValue() { var resistor = new Resistor(colorCode.Object); Assert.AreNotEqual(130000, resistor.CalculateOhmValue("Black", "Orange", "Red", "Red")); }