public ItemCategoryViewer()
 {
     InitializeComponent();
     MyController = new ItemCategoryController(this);
     Controller   = MyController;
     CleanEmptyReportButtons();
 }
        public void AddNewItemCategoryTest()
        {
            //Arrange
            //Instantiate controller
            ItemCategoryController controller = new ItemCategoryController()
            {
                CurrentUserName = "******",
                context         = this.context
            };

            controller.ModelState.Clear();

            //create new ViewModel to Save via controller
            ItemCategoryViewModel newItemCategory = new ItemCategoryViewModel()
            {
                ItemCategoryId = IdService.GetNewItemCategoryId(context),
                Name           = "TEST"
            };

            //Act
            ActionResult result = controller.Save(newItemCategory);

            //Assert
            Assert.IsNotNull(result);
        }
        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 void Index()
        {
            // Arrange
            ItemCategoryController controller = new ItemCategoryController();

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }