Esempio n. 1
0
 public HomeModule()
 {
     Get["/"]       = _ => View["index.cshtml"];
     Get["/sorted"] = _ => {
         CombinationGenerator myGenerator = new CombinationGenerator();
         string        userInput          = Request.Query["userInput"];
         decimal       inputAsDecimal     = Decimal.Parse(userInput);
         List <string> coins = myGenerator.Generate(inputAsDecimal);
         return(View["result.cshtml", coins]);
     };
 }
        public void Generate_SortCoins_CountAllPennies()
        {
            decimal       change = 0.04m;
            List <string> sorted = new List <string> {
                "0 quarter(s)", "0 dime(s)", "0 nickel(s)", "4 pennies"
            };
            CombinationGenerator myGenerator = new CombinationGenerator();

            List <string> result = myGenerator.Generate(change);

            Assert.Equal(sorted, result);
        }
        public void Generate_SortCoins_CountAllQuarters()
        {
            //arrange
            decimal       change = 0.75m;
            List <string> sorted = new List <string> {
                "3 quarter(s)", "0 dime(s)", "0 nickel(s)", "0 pennies"
            };
            CombinationGenerator myGenerator = new CombinationGenerator();

            //act
            List <string> result = myGenerator.Generate(change);

            //assert
            Assert.Equal(sorted, result);
        }