public void FindAllNeededCoins_SingleOneCoinMatch()
        {
            CoinFinder myFinder = new CoinFinder(new int[] { 5, 2, 1 });
            List<int> expected = new List<int>() { 1 };

            CollectionAssert.AreEqual(expected, myFinder.FindAllNeededCoins(1));
        }
        public void FindAllNeededCoins_EightTest()
        {
            CoinFinder myFinder = new CoinFinder(new int[] { 5, 2, 1 });
            List<int> expected = new List<int>() { 1, 2, 5 };

            CollectionAssert.AreEqual(expected, myFinder.FindAllNeededCoins(8));
        }
        public void FindAllNeededCoins_HomeworkExample()
        {
            CoinFinder myFinder = new CoinFinder(new int[] { 5, 2, 1 });
            List<int> expected = new List<int>() { 1, 2, 5, 5, 5, 5, 5, 5 };

            CollectionAssert.AreEqual(expected, myFinder.FindAllNeededCoins(33));
        }
コード例 #4
0
        public void Constructor_Test()
        {
            int        UserCents = 100;
            CoinFinder coinTest  = new CoinFinder(UserCents);

            Assert.AreEqual(UserCents, coinTest.GetUserCents());
        }
コード例 #5
0
    public static void Main()
    {
        Console.WriteLine("Please enter then amount of cents you would like change for.");
        int        MyTotalCents  = int.Parse(Console.ReadLine());
        CoinFinder CoinFinderObj = new CoinFinder(MyTotalCents);

        CoinFinderObj.CalcChange();
        PrintChange(MyTotalCents, CoinFinderObj);
    }
コード例 #6
0
        public void CalcChange_TestOneForAll()
        {
            CoinFinder coinTest = new CoinFinder(41);

            coinTest.CalcChange();
            Dictionary <string, int> testDict = new Dictionary <string, int> {
                { "Quarter", 1 }, { "Dime", 1 }, { "Nickel", 1 }, { "Penny", 1 }
            };

            CollectionAssert.AreEqual(testDict, coinTest.GetChangeAmt());
        }
コード例 #7
0
 public static void PrintChange(int totalCents, CoinFinder myObj)
 {
     Console.WriteLine("Your change for " + totalCents + ":");
     foreach (KeyValuePair <string, int> kvp in myObj.GetChangeAmt())
     {
         if (kvp.Value == 0)
         {
             continue;
         }
         Console.WriteLine("{0} : {1}.", kvp.Key, kvp.Value);
     }
 }