public void CalculateOhmValueRangeTest() { OhmRange range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "GD"); Assert.AreEqual(range.MinValue, 4465); Assert.AreEqual(range.MaxValue, 4935); }
public void ToleranceTest() { OhmRange range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "SR"); Assert.AreEqual(range.MinValue, 4230); Assert.AreEqual(range.MaxValue, 5170); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "GD"); Assert.AreEqual(range.MinValue, 4465); Assert.AreEqual(range.MaxValue, 4935); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "BK"); Assert.AreEqual(range.MinValue, 4700); Assert.AreEqual(range.MaxValue, 4700); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "BN"); Assert.AreEqual(range.MinValue, 4653); Assert.AreEqual(range.MaxValue, 4747); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "RD"); Assert.AreEqual(range.MinValue, 4606); Assert.AreEqual(range.MaxValue, 4794); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "OG"); Assert.AreEqual(range.MinValue, 4700); Assert.AreEqual(range.MaxValue, 4700); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "YE"); Assert.AreEqual(range.MinValue, 4465); Assert.AreEqual(range.MaxValue, 4935); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "GN"); Assert.AreEqual(range.MinValue, 4676.5); Assert.AreEqual(range.MaxValue, 4723.5); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "BU"); Assert.AreEqual(range.MinValue, 4688.25); Assert.AreEqual(range.MaxValue, 4711.75); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "VT"); Assert.AreEqual(range.MinValue, 4695.3); Assert.AreEqual(range.MaxValue, 4704.7); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "GY"); Assert.AreEqual(range.MinValue, 4697.65); Assert.AreEqual(range.MaxValue, 4702.35); range = calculator.CalculateOhmValueRange("YE", "VT", "RD", "WH"); Assert.AreEqual(range.MinValue, 4700); Assert.AreEqual(range.MaxValue, 4700); }
public ActionResult Calculator(Models.CalculatorViewModel viewModel) { ViewBag.Message = "Electronic Color Code Calculator"; ColorCodes colorCodes = new ColorCodes(); viewModel.ColorCodes = colorCodes.getColorCodes().Values; if (!ModelState.IsValid) { return(View(viewModel)); } else { IOhmValueCalculator calculator = new OhmValueCalcuator(new ColorCodes()); OhmRange range = calculator.CalculateOhmValueRange(viewModel.SelectedAColor, viewModel.SelectedBColor, viewModel.SelectedCColor, viewModel.SelectedDColor); viewModel.OhmValueMin = range.MinValue; viewModel.OhmValueMax = range.MaxValue; return(View(viewModel)); } }