Beispiel #1
0
        public PartialViewResult _10([FromBody] Ex10ViewModel vm)
        {
            Ex10 ex = new Ex10(vm.ToKeyValuePairs());

            vm.SubTotal = ex.GetSubTotal();
            vm.Tax      = ex.GetTax();
            vm.Total    = ex.GetTotal();

            return(PartialView("_10_partial", vm));
        }
Beispiel #2
0
        public void _10_WhenInputIsX_SholudReturnCorrectAnswer()
        {
            IList <KeyValuePair <int, int> > items = new List <KeyValuePair <int, int> >();

            items.Add(new KeyValuePair <int, int>(2, 25));
            items.Add(new KeyValuePair <int, int>(1, 10));
            items.Add(new KeyValuePair <int, int>(1, 4));

            float expectedSubTotal = 64.0F;
            float expectedTax      = 3.52F;
            float expectedTotal    = 67.52F;
            // Act
            Ex10  ex             = new Ex10(items);
            float actualSubTotal = ex.GetSubTotal();
            float actualTax      = ex.GetTax();
            float actualTotal    = ex.GetTotal();

            // Assert
            Assert.AreEqual(expectedSubTotal, actualSubTotal);
            Assert.AreEqual(expectedTax, actualTax);
            Assert.AreEqual(expectedTotal, actualTotal);
        }