Exemplo n.º 1
0
        public void PayMoreThanPriceThenReturnChangeCorrectly(int price, int amount, int expected)
        {
            var sut    = new ChangeCalculator();
            var result = sut.GetChange(price, amount);

            Assert.Equal(expected, result);
        }
        public void ChangeCalculatorReturnsTwoQuartersAndANickelFor55Cents()
        {
            var change = ChangeCalculator.GetChange(0.55d);

            change.Coins.Count.ShouldBe(3);
            change.Coins.Count(c => c.MonetaryValue == 0.25).ShouldBe(2);
            change.Coins.Count(c => c.MonetaryValue == 0.05).ShouldBe(1);
        }
        public void ChangeCalculatorReturnsThreeQuartersAndADimeFor85Cents()
        {
            var change = ChangeCalculator.GetChange(0.85d);

            change.Coins.Count.ShouldBe(4);
            change.Coins.Count(c => c.MonetaryValue == 0.25).ShouldBe(3);
            change.Coins.Count(c => c.MonetaryValue == 0.1).ShouldBe(1);
        }
        public void ChangeCalculatorReturnsAQuarterFor25()
        {
            var change = ChangeCalculator.GetChange(0.25d);

            change.Coins.ShouldNotBeEmpty();
            change.Value.ShouldBe(0.25d);
            change.Coins.Count.ShouldBe(1);
        }
        public void ChangeCalculatorReturnsAQuarterANickelAndADimeFor40Cents()
        {
            var change = ChangeCalculator.GetChange(0.4d);

            change.Coins.Count.ShouldBe(3);
            change.Coins.Count(c => c.MonetaryValue == 0.25).ShouldBe(1);
            change.Coins.Count(c => c.MonetaryValue == 0.05).ShouldBe(1);
            change.Coins.Count(c => c.MonetaryValue == 0.1).ShouldBe(1);
        }
        public void ChangeCalculatorReturnsThreeQuartersFor75cents()
        {
            var change = ChangeCalculator.GetChange(0.75d);

            change.Coins.ShouldNotBeEmpty();
            change.Value.ShouldBe(0.75d);
            change.Coins.Count.ShouldBe(3);
            change.Coins.Count(c => c.MonetaryValue == 0.25).ShouldBe(3);
        }
Exemplo n.º 7
0
        public void GetChange_NotNull()
        {
            var change = ChangeCalculator.GetChange(0, 0);

            Assert.IsNotNull(change);
        }
Exemplo n.º 8
0
        public void GetChange_Various_CorrectChange(int receivedMoney, int productPrice, int expected)
        {
            var change = ChangeCalculator.GetChange(receivedMoney, productPrice);

            Assert.AreEqual(expected, change);
        }