コード例 #1
0
        public void TestMultiplierBand()
        {
            MultiplierBand band = new MultiplierBand();

            band.Color = ResistorMultiplier.Red;

            Assert.AreEqual(100, band.Value);
        }
コード例 #2
0
        public Resistor makeFourBandResistor()
        {
            Band           firstBand  = new Band();
            Band           secondBand = new Band();
            MultiplierBand thirdBand  = new MultiplierBand();
            ToleranceBand  fourthBand = new ToleranceBand();

            Resistor resistor = new Resistor();

            resistor.Bands.Add(firstBand);
            resistor.Bands.Add(secondBand);
            resistor.Bands.Add(thirdBand);
            resistor.Bands.Add(fourthBand);

            return(resistor);
        }
コード例 #3
0
        public void TestResistorFromFactoryWithParamMethod()
        {
            Band           firstBand  = new Band();
            Band           secondBand = new Band();
            MultiplierBand thirdBand  = new MultiplierBand();
            ToleranceBand  fourthBand = new ToleranceBand();

            Resistor resistor = ResistorFactory.fourBands(firstBand, secondBand, thirdBand, fourthBand);

            ((Band)resistor.Bands[0]).Color           = ResistorColor.Orange;
            ((Band)resistor.Bands[1]).Color           = ResistorColor.Brown;
            ((MultiplierBand)resistor.Bands[2]).Color = ResistorMultiplier.Black;
            ((ToleranceBand)resistor.Bands[3]).Color  = ResistorTolerance.Gold;

            Assert.AreEqual(31, resistor.Value);
        }
コード例 #4
0
        public void TestFourBands()
        {
            Band           firstBand  = new Band();
            Band           secondBand = new Band();
            MultiplierBand thirdBand  = new MultiplierBand();
            ToleranceBand  fourthBand = new ToleranceBand();

            //25000 +-25%
            firstBand.Color  = ResistorColor.Red;
            secondBand.Color = ResistorColor.Green;
            thirdBand.Color  = ResistorMultiplier.Orange;
            fourthBand.Color = ResistorTolerance.Silver;

            float value = ((10 * firstBand.Value) + secondBand.Value) * thirdBand.Value;

            Assert.AreEqual(25000, value);
        }