public void Coin100ConstructorTest() { Coin100 coin100 = new Coin100(); //assert coin of $1 has diameter of 26.50mm, and thickness of 2.00mm Assert.AreEqual(26.50m, coin100.diameter); Assert.AreEqual(2.00m, coin100.thickness); }
public void Coin100AddJarTest() { Coin100 coin100 = new Coin100(); Jar jar = new Jar(); //add the $1 coin to the jar coin100.AddToJar(jar); //assert jar.Coin100Counter is 1 and jar.CurrentAmount is $1.00 Assert.AreEqual(1, jar.Coin100Counter); Assert.AreEqual(1.00m, jar.CurrentAmount); }
public void FillUpwithRandomCoinTest() { Jar jar = new Jar(); // The Random() constructor uses the system clock to provide a seed value. Random rnd = new Random(); // coin.AddToJar failure indicates jar full. var addJarSucceeded = false; do { // Generate random int with range of [1,6] // 1-- 1 cent coin // 2-- 5 cent coin // 3-- 10 cent coin // 4-- 25 cent coin // 5-- 50 cent coin // 6-- $1 coin var coinType = rnd.Next(1, 7); switch (coinType) { case 1: addJarSucceeded = new Coin001().AddToJar(jar); break; case 2: addJarSucceeded = new Coin005().AddToJar(jar); break; case 3: addJarSucceeded = new Coin010().AddToJar(jar); break; case 4: addJarSucceeded = new Coin025().AddToJar(jar); break; case 5: addJarSucceeded = new Coin050().AddToJar(jar); break; default: addJarSucceeded = new Coin100().AddToJar(jar); break; } } //loop while last filling succeeded while (addJarSucceeded); jar.PrintJar(); }
public void FillUpwith100CentCoinTest() { Jar jar = new Jar(); Coin100 coin100 = new Coin100(); //fill up with $1 coins while (coin100.AddToJar(jar)) { ; } jar.PrintJar(); }