Esempio n. 1
0
        public void FindByIdTestNotNull()
        {
            // Act
            var result = itemCategoryRepository.FindById(1);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ItemCategory));
        }
        public void EditItemCategoryTest()
        {
            //Arrange
            string expected = "Testing EditSupplier";

            //Instantiate controller
            ItemCategoryController controller = new ItemCategoryController()
            {
                CurrentUserName = "******",
                context         = this.context
            };

            controller.ModelState.Clear();

            //Assemble a ItemCategory ViewModel from existing test object
            ItemCategory          ic = context.ItemCategory.Where(x => x.Name == "TEST").First();
            ItemCategoryViewModel VM = new ItemCategoryViewModel()
            {
                ItemCategoryId = ic.ItemCategoryId,
                Name           = ic.Name,
                Description    = expected
            };

            //Act
            //pass ViewModel to controller
            controller.Save(VM);

            var result = itemcategoryRepository.FindById(VM.ItemCategoryId);

            //Assert
            //check that entry has been updated in db
            Assert.AreEqual(expected, result.Description);
        }
 public ItemCategory FindItemCategoryByItemCategoryId(int itemCategoryId)
 {
     return(itemCategoryRepository.FindById(itemCategoryId));
 }