public void TestMultiplierBand() { MultiplierBand band = new MultiplierBand(); band.Color = ResistorMultiplier.Red; Assert.AreEqual(100, band.Value); }
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); }
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); }
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); }