示例#1
0
        public void Add_NewDrink_DrinkAddedAndSaved()
        {
            // Arrange
            var added = false;
            var saved = false;
            var drink = new DrinkDTO {
                Name = "Fanta", Quantity = 3
            };

            _drinkRepositoryMock.Setup(s => s.Insert(It.IsAny <Drink>())).Callback(() => added = true);
            _drinkRepositoryMock.Setup(s => s.Save()).Callback(() => saved = true);
            _drinkRepositoryMock.Setup(s => s.Get(It.IsAny <Expression <Func <Drink, bool> > >(),
                                                  It.IsAny <Func <IQueryable <Drink>, IOrderedQueryable <Drink> > >())).Returns(new List <Drink>());

            // Act
            _drinkService.AddDrink(drink);

            // Assert
            Assert.IsTrue(added);
            Assert.IsTrue(saved);
        }
示例#2
0
 public IHttpActionResult Add(DrinkDTO drink)
 {
     _drinkService.AddDrink(drink);
     return(Ok());
 }
示例#3
0
 public string SaveDrink(Drink drink)
 {
     return(drinkService.AddDrink(drink));
 }
 public void AddDrinkToMachine(int machineId, int drinkId, int count)
 {
     _drinkService.AddDrink(machineId, drinkId, count);
 }