Ejemplo n.º 1
0
        public int CalculateOhmValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor)
        {
            var color1 = ColorCodes.Parse(bandAColor);
            var color2 = ColorCodes.Parse(bandBColor);
            var color3 = ColorCodes.Parse(bandCColor);
            var color4 = ColorCodes.Parse(bandDColor);

            return(CalculateOhmValue(color1.FourBand.FirstPosition, color2.FourBand.SecondPosition, color3.FourBand.Multiplier));
        }
        public void Test_Parse()
        {
            var result = ColorCodes.Parse("RED");

            result.Should().NotBeNull();
            result.Should().BeOfType <RedColorCode>();

            result = ColorCodes.Parse("white");
            result.Should().BeOfType <WhiteColorCode>();

            result = ColorCodes.Parse(" grey ");
            result.Should().BeOfType <GreyColorCode>();

            Action act = () => ColorCodes.Parse(String.Empty);

            act.Should().Throw <ArgumentNullException>();

            act = () => ColorCodes.Parse("CHARTREUSE");
            act.Should().Throw <ArgumentException>().And.Message.Should().Contain("Invalid color name specified");
        }