public void Coin050ConstructorTest() { Coin050 coin050 = new Coin050(); //assert coin of 50 cent has diameter of 30.61mm, and thickness of 2.15mm Assert.AreEqual(30.61m, coin050.diameter); Assert.AreEqual(2.15m, coin050.thickness); }
public void Coin050AddJarTest() { Coin050 coin050 = new Coin050(); Jar jar = new Jar(); //add the 50-cent coin to the jar coin050.AddToJar(jar); //assert jar.Coin050Counter is 1 and jar.CurrentAmount is $0.50 Assert.AreEqual(1, jar.Coin050Counter); Assert.AreEqual(0.50m, 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 FillUpwith50CentCoinTest() { Jar jar = new Jar(); Coin050 coin050 = new Coin050(); //fill up with 50-cent coins while (coin050.AddToJar(jar)) { ; } jar.PrintJar(); }