public void WhenGetAll_Returns_404_IfNoData()
        {
            // Arrange
            IEnumerable<BudgetItem> fakeItems = GetNoItems();
            // setup
            _itemRepository.Setup(x => x.GetAll()).Returns(fakeItems);

            ItemsController controller = new ItemsController(_itemRepository.Object);

            // Act

            IHttpActionResult actionResult = controller.Get();
            // Assert
            Assert.IsNotNull(actionResult, "Result is null");
            Assert.IsInstanceOf(typeof(NotFoundResult), actionResult, "It should return 404");
        }
        public void WhenGet_Returns_404_IfNoData()
        {
            // Arrange
            int fakeId = -10;
            IEnumerable<BudgetItem> fakeItems = GetFakeItems();
            // setup
            _itemRepository.Setup(x => x.GetItem(fakeId)).Returns(fakeItems.FirstOrDefault(p => p.Id == fakeId));

            ItemsController controller = new ItemsController(_itemRepository.Object);

            // Act

            IHttpActionResult actionResult = controller.Get(fakeId);
            // Assert
            Assert.IsNotNull(actionResult, "Result is null");
            Assert.IsInstanceOf(typeof(NotFoundResult), actionResult, "It should return 404");
        }
        public void WhenGet_Returns_Item()
        {
            var fakeId = 1;
            // Arrange
            IEnumerable<BudgetItem> fakeItems = GetFakeItems();
            // setup
            _itemRepository.Setup(x => x.GetItem(fakeId)).Returns(fakeItems.FirstOrDefault(p => p.Id == fakeId));

            ItemsController controller = new ItemsController(_itemRepository.Object);

            // Act
            var response = controller.Get(fakeId);
            var item = response as OkNegotiatedContentResult<BudgetItem>;
            // Assert

            Assert.IsNotNull(item, "Result is null");
            Assert.IsInstanceOf(typeof(BudgetItem), item.Content, "Wrong Model");
            Assert.AreEqual(fakeId, item.Content.Id, "Got wrong item.");
        }
        public void WhenGetAll_Returns_AllItems()
        {
            // Arrange
            IEnumerable<BudgetItem> fakeItems = GetFakeItems();
            // setup
            _itemRepository.Setup(x => x.GetAll()).Returns(fakeItems);

            ItemsController controller = new ItemsController(_itemRepository.Object);

            // Act
            var response = controller.Get();
            var items = response as OkNegotiatedContentResult<IEnumerable<BudgetItem>>;
            // Assert

            Assert.IsNotNull(items, "Result is null");
            Assert.IsInstanceOf(typeof(IEnumerable<BudgetItem>), items.Content, "Wrong Model");
            Assert.AreNotEqual(3, items.Content.Count(), "Got wrong number of items.");
        }