public void Two_snackpile_instances_with_same_values_are_equal()
        {
            var snack = Snack.Chocolate;
            SnackPile snackPile1 = new SnackPile(snack, 1, 1m);
            SnackPile snackPile2 = new SnackPile(snack, 1, 1m);

            snackPile1.Equals(snackPile2).Should().BeTrue();
        }
        public void Two_snackpile_instances_with_same_values_return_same_hashcode()
        {
            var snack = Snack.Chocolate;
            SnackPile snackPile1 = new SnackPile(snack, 1, 1m);
            SnackPile snackPile2 = new SnackPile(snack, 1, 1m);

            snackPile1.GetHashCode().Equals(snackPile2.GetHashCode()).Should().BeTrue();
        }
        public void Cannot_create_snackpile_with_invalid_quantity()
        {
            Action action = () =>
            {
                var snackPile = new SnackPile(Snack.Chocolate, -1, 0);
            };

            action.ShouldThrow<InvalidOperationException>();
        }
        public void Cannot_create_snackpile_with_price_lower_than_machine_can_handle()
        {
            Action action = () =>
            {
                var snackPile = new SnackPile(Snack.Chocolate, 1, 0.009m);
            };

            action.ShouldThrow<InvalidOperationException>();
        }
        public void throw_when_price_more_precise_than_one_cent()
        {
            Action action = () =>
            {
                var snackPile = new SnackPile(Chocolate, 0, 1.123m);
            };

            action.Should().Throw <InvalidOperationException>();
        }
        public void cannot_create_with_negative_price()
        {
            Action action = () =>
            {
                var snackPile = new SnackPile(Chocolate, 0, -1);
            };

            action.Should().Throw <InvalidOperationException>();
        }
Exemplo n.º 7
0
        public virtual string CanBuySnack(int position)
        {
            SnackPile snackPile = GetSnacksPile(position);

            if (snackPile.Quantity == 0)
            {
                return("The snack pile is empty");
            }

            if (MoneyInTransaction < snackPile.Price)
            {
                return("Not enough money");
            }

            if (!MoneyInside.CanAllocate(MoneyInTransaction - snackPile.Price))
            {
                return("Not enough change");
            }

            return(string.Empty);
        }
Exemplo n.º 8
0
 public virtual void LoadSnacks(int position, SnackPile snackPile)
 {
     Slot slot = GetSlot(position);
     slot.SnackPile = snackPile;
 }
 public SnackPileViewModel(SnackPile snackPile)
 {
     _snackPile = snackPile;
 }
Exemplo n.º 10
0
        public void Cannot_create_snackpile_with_price_having_more_than_2_decimal_digit()
        {
            Action action = () => { var snack = new SnackPile(Snack.Chocolate, 1, 1.234m); };

            action.Should().Throw <InvalidOperationException>();
        }
Exemplo n.º 11
0
        public void Cannot_create_snackpile_with_negative_quantity()
        {
            Action action = () => { var snack = new SnackPile(Snack.Chocolate, -1, 1m); };

            action.Should().Throw <InvalidOperationException>();
        }
Exemplo n.º 12
0
        public virtual void LoadSnacks(int position, SnackPile snackPile)
        {
            Slot slot = GetSlot(position);

            slot.SnackPile = snackPile;
        }
Exemplo n.º 13
0
 public SnackPileViewModel(SnackPile snackPile)
 {
     _snackPile = snackPile;
 }
Exemplo n.º 14
0
 public Slot(int position, SnackPile snackPile)
 {
     this.Position  = position;
     this.SnackPile = snackPile;
 }
Exemplo n.º 15
0
 public Slot(int position)
 {
     Position  = position;
     SnackPile = new SnackPile(null, 0, 0m);
 }