public void Setup()
 {
     _controller = new FoodItemController(_mapper, _unitOfWork);
     _foodItemRepository = _unitOfWork.FoodItemRepository as FakeRepository<Data.Models.FoodItem>;
     _foodItem = _mapper.Map<FoodItem>(_foodItemRepository.Insert(new Data.Models.FoodItem()
     {
         BarCode = new Data.Models.BarCode { Identifier = "123", Type = Data.Models.BarCodeType.Regular },
         Name = "Juice",
         ShelfLifeDays = 4
     }));
 }
        public async Task Post()
        {
            var foodItem = new FoodItem()
            {
                BarCode = new BarCode { Identifier = "456", Type = BarCodeType.Regular },
                Id = "2",
                Name = "Lettuce",
                ShelfLifeDays = 5
            };
            await _controller.Post(foodItem);

            var result = await _controller.Get() as OkNegotiatedContentResult<IEnumerable<FoodItem>>;
            Assert.AreEqual(2, result.Content.Count());
        }
Example #3
0
        private void btnCreate_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            var foodItem = new FoodItem
            {
                Id = Guid.NewGuid().ToString(),
                Name = tbName.Text,
                ShelfLifeDays = int.Parse(tbShelfLife.Text),
                BarCode = new BarCode
                {
                    Identifier = "23",
                    Type = BarCodeType.QR
                }
            };
            _api.Create(foodItem);

        }
 public void Cleanup()
 {
     _foodItemRepository.Clear();
     _foodItem = null;
 }