Example #1
0
        static void Main(string[] ringColors)
        {
            try
            {
                ColorCode_DIN_IEC_62_FromJSONProvider colorCodesProvider = new ColorCode_DIN_IEC_62_FromJSONProvider("color_codes.json");
                IReadOnlyList <ColorCode_DIN_IEC_62>  colorCodes         = colorCodesProvider.LoadColorCodes();

                if (colorCodesProvider.ValidationErrorMessages.Any())
                {
                    ((List <string>)colorCodesProvider.ValidationErrorMessages).ForEach(vem => Console.WriteLine(vem));
                    return;
                }

                Resistor_DIN_IEC_62 resistor = Resistor_DIN_IEC_62.Create(ringColors, colorCodes);

                Console.WriteLine(resistor.ResistorValue());
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine(String.Format(e.Message, e.FileName));
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
Example #2
0
        public void Create_AllowedValues_NewResistor(int baseValue, int multiplier, double tolerance)
        {
            #region ARRANGE

            #endregion

            #region ACT

            var resistor = Resistor_DIN_IEC_62.Create(baseValue, multiplier, tolerance);

            #endregion

            #region ASSERT

            Assert.IsTrue(resistor != null);

            #endregion
        }
Example #3
0
        public void ResistorValue_ResistorValues_CorrectlyCalculatdResistorValueWithUnits(
            int baseResistorValue, int multiplier, double tolerance, string expectedValue)
        {
            #region ARRANGE

            #endregion

            #region ACT

            var    resistor      = Resistor_DIN_IEC_62.Create(baseResistorValue, multiplier, tolerance);
            string resistorValue = resistor.ResistorValue();

            #endregion

            #region ASSERT

            Assert.AreEqual <string>(expectedValue, resistorValue);

            #endregion
        }
Example #4
0
        public void Create_ColorStringArray_NewResistor(string[] ringColors)
        {
            #region ARRANGE

            ColorCode_DIN_IEC_62_FromJSONProvider colorCodesProvider = new ColorCode_DIN_IEC_62_FromJSONProvider("color_codes.json");
            IReadOnlyList <ColorCode_DIN_IEC_62>  colorCodes         = colorCodesProvider.LoadColorCodes();

            #endregion

            #region ACT

            var resistor = Resistor_DIN_IEC_62.Create(ringColors, colorCodes);

            #endregion

            #region ASSERT

            Assert.IsTrue(resistor != null);

            #endregion
        }