private void CalcTip()
 {
     _calculator.CalcTip();
     tipTxt = Math.Round(_calculator.Tip, 2).ToString();
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("TipTxt"));
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GrandTotalTxt"));
 }
        public void CalculateTipOneHundredPercent()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 10,
                TipPercent = 100
            };

            tipCalculator.CalcTip();

            Assert.AreEqual(tipCalculator.Tip, 10);
        }
        public void CalculateTipZeroPercent()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 10,
                TipPercent = 0
            };

            tipCalculator.CalcTip();

            Assert.AreEqual(tipCalculator.Tip, 0);
        }
        public void CalculateGrandTotal()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 10,
                TipPercent = 50
            };

            tipCalculator.CalcTip();

            Assert.AreEqual(tipCalculator.GrandTotal, 15);
        }
        public void CalculateTipTwentyFivePercent()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 10,
                TipPercent = 25
            };

            tipCalculator.CalcTip();

            Assert.AreEqual(tipCalculator.Tip, 2.50);
        }
Exemple #6
0
        public void CalculateTipTenPercent()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 10,
                TipPercent = 10
            };

            tipCalculator.CalcTip();

            Assert.AreEqual(tipCalculator.Tip, (decimal)1.00);
        }
        public void CalcTip_18PercentTip100Total_GrandTotal118()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 100,
                TipPercent = 18
            };

            tipCalculator.CalcTip();

            Assert.AreEqual(decimal.Parse("118"), tipCalculator.GrandTotal);
        }
Exemple #8
0
        public void SplitCheck_ThreePersons_TotalPersonEqualsOneHalfGrandTotal()
        {
            var tipCalculator = new TipCalculator
            {
                Total           = (decimal)149.36,
                TipPercent      = 15,
                NumberOfPersons = 3
            };

            tipCalculator.CalcTip();
            tipCalculator.SplitGrandTotal();

            Assert.AreEqual(tipCalculator.TotalPerPerson, Math.Round((tipCalculator.GrandTotal / 3), 2));
        }
Exemple #9
0
        public void SplitCheck_OnePerson_TotalPersonEqualsGrandTotal()
        {
            var tipCalculator = new TipCalculator
            {
                Total           = (decimal)149.36,
                TipPercent      = 15,
                NumberOfPersons = 1
            };

            tipCalculator.CalcTip();
            tipCalculator.SplitGrandTotal();

            Assert.AreEqual(tipCalculator.TotalPerPerson, tipCalculator.GrandTotal);
        }
Exemple #10
0
        public void RoundTipThenCalcTip_Total49_36TipPercent15_GrandTotal171_76TipShouldBe22_40()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = (decimal)149.36,
                TipPercent = 15
            };

            tipCalculator.RoundTotal();
            tipCalculator.CalcTip();

            Assert.AreEqual((decimal)171.76, tipCalculator.GrandTotal);
            Assert.AreEqual((decimal)22.40, tipCalculator.Tip);
        }
Exemple #11
0
        public void RoundTip_Total49_36TipPercent18_GrandTotal176TipShouldBe26_64()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = (decimal)149.36,
                TipPercent = 18
            };

            tipCalculator.CalcTip();
            tipCalculator.RoundTotal();

            Assert.AreEqual((decimal)176.00, tipCalculator.GrandTotal);
            Assert.AreEqual((decimal)26.64, tipCalculator.Tip);
        }
Exemple #12
0
        public void ResetCalculator_CalculatorPopulatedWithValidValues_CalculatorResetToOriginalState()
        {
            var tipCalculator = new TipCalculator
            {
                Total      = 10,
                TipPercent = 50
            };

            var newTipCalculator = new TipCalculator();

            tipCalculator.CalcTip();
            tipCalculator.Reset();

            Assert.AreEqual(newTipCalculator.GrandTotal, tipCalculator.GrandTotal);
            Assert.AreEqual(newTipCalculator.Tip, tipCalculator.Tip);
            Assert.AreEqual(newTipCalculator.TipPercent, tipCalculator.TipPercent);
            Assert.AreEqual(newTipCalculator.Total, tipCalculator.Total);
            Assert.AreEqual(newTipCalculator.NumberOfPersons, tipCalculator.NumberOfPersons);
            Assert.AreEqual(newTipCalculator.SavedGrandTotal, tipCalculator.SavedGrandTotal);
            Assert.AreEqual(newTipCalculator.SavedTip, tipCalculator.SavedTip);
            Assert.AreEqual(newTipCalculator.TotalPerPerson, tipCalculator.TotalPerPerson);
        }