public void TestEdit_WhenItemNotExists()
        {
            InventoryPartView        expectedObject = MockObjectsUtil.GetMockInventoryPartView(1);
            List <InventoryPartView> data           = new List <InventoryPartView>()
            {
                MockObjectsUtil.GetMockInventoryPartView(1)
            };
            Mock <InventoryPartManager> mockManager = new Mock <InventoryPartManager>();

            mockManager.Setup(x => x.UpdateInventoryPart(It.IsAny <InventoryPartView>()));
            InventoryPartsController controller = new InventoryPartsController(mockManager.Object);
            ViewResult result = controller.Edit(2) as ViewResult;

            Assert.IsNull(result);
        }
        public void TestEdit_WhenIdIsNull()
        {
            InventoryPartView        expectedObject = MockObjectsUtil.GetMockInventoryPartView(1);
            List <InventoryPartView> data           = new List <InventoryPartView>()
            {
                MockObjectsUtil.GetMockInventoryPartView(1)
            };
            Mock <InventoryPartManager> mockManager = new Mock <InventoryPartManager>();

            mockManager.Setup(x => x.UpdateInventoryPart(It.IsAny <InventoryPartView>()));
            InventoryPartsController controller = new InventoryPartsController(mockManager.Object);
            HttpStatusCodeResult     result     = controller.Edit((int?)null) as HttpStatusCodeResult;

            Assert.AreEqual(400, result.StatusCode);
        }
        public void TestEdit_WhenItemExists()
        {
            InventoryPartView        expectedObject = MockObjectsUtil.GetMockInventoryPartView(1);
            List <InventoryPartView> data           = new List <InventoryPartView>()
            {
                MockObjectsUtil.GetMockInventoryPartView(1)
            };
            Mock <InventoryPartManager> mockManager = new Mock <InventoryPartManager>();

            mockManager.Setup(x => x.UpdateInventoryPart(It.IsAny <InventoryPartView>()));
            mockManager.Setup(x => x.GetInventoryPartFromId(It.IsAny <int?>())).Returns(expectedObject);
            InventoryPartsController controller = new InventoryPartsController(mockManager.Object);
            ViewResult result = controller.Edit(1) as ViewResult;

            Assert.IsNotNull(result);
            InventoryPartView actualObject = (InventoryPartView)result.Model;

            Assert.AreEqual(expectedObject.ID, actualObject.ID);
        }
        public void TestEdit_WithParameter()
        {
            InventoryPartView inputObject = new InventoryPartView()
            {
                ID                = 2,
                Name              = "test 2",
                ReorderLevel      = 50,
                AvailabeNoOfUnits = 100,
                UnitPrice         = 10
            };

            InventoryPartView        expectedObject = MockObjectsUtil.GetMockInventoryPartView(1);
            List <InventoryPartView> data           = new List <InventoryPartView>()
            {
                MockObjectsUtil.GetMockInventoryPartView(1)
            };
            Mock <InventoryPartManager> mockManager = new Mock <InventoryPartManager>();

            mockManager.Setup(x => x.UpdateInventoryPart(It.IsAny <InventoryPartView>()));
            InventoryPartsController controller = new InventoryPartsController(mockManager.Object);
            ViewResult result = controller.Edit(inputObject) as ViewResult;

            Assert.IsNull(result);
        }