public ActionResult Calculate(OhmValueCalculatorPostModel postModel)
        {
            var ohmValue = _ohmValueCalculator.CalculateOhmValues(postModel.ColorBandA, postModel.ColorBandB,
                                                                  postModel.ColorBandC, postModel.ColorBandD);

            var tolerance = _resistorColorCodeRepository
                            .FindBy(ResistorColorCode.ParseResistorColor(postModel.ColorBandD))
                            .Tolerance;

            return(Json(new OhmValueCalculatorResponseModel
            {
                OhmValue = ohmValue.ToFormattedString(),
                Tolerance = tolerance?.ToString("P")
            }));
        }
Exemplo n.º 2
0
        public void Calculate_YellowVioletBlackGold_ReturnsCorrectOhmValue()
        {
            var ohmValue = _ohmValueCalculator.CalculateOhmValues("Yellow", "Violet", "Black", "Gold");

            ohmValue.ShouldBe(47);
        }