Exemplo n.º 1
0
        public void Coin025ConstructorTest()
        {
            Coin025 coin025 = new Coin025();

            //assert coin of 25 cent has diameter of 24.26mm, and thickness of 1.75mm
            Assert.AreEqual(24.26m, coin025.diameter);
            Assert.AreEqual(1.75m, coin025.thickness);
        }
Exemplo n.º 2
0
        public void Coin025AddJarTest()
        {
            Coin025 coin025 = new Coin025();
            Jar     jar     = new Jar();

            //add the 25-cent coin to the jar
            coin025.AddToJar(jar);

            //assert jar.Coin025Counter is 1 and jar.CurrentAmount is $0.25
            Assert.AreEqual(1, jar.Coin025Counter);
            Assert.AreEqual(0.25m, 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();
        }
Exemplo n.º 4
0
        public void FillUpwith25CentCoinTest()
        {
            Jar     jar     = new Jar();
            Coin025 coin025 = new Coin025();

            //fill up with 25-cent coins
            while (coin025.AddToJar(jar))
            {
                ;
            }

            jar.PrintJar();
        }