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

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

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

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

            Assert.AreEqual(400, result.StatusCode);
        }
        public void TestDelete_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.DeleteInventoryPart(It.IsAny <InventoryPartView>()));
            mockManager.Setup(x => x.GetInventoryPartFromId(It.IsAny <int?>())).Returns(expectedObject);
            InventoryPartsController controller = new InventoryPartsController(mockManager.Object);
            ViewResult result = controller.Delete(1) as ViewResult;

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

            Assert.AreEqual(expectedObject.ID, actualObject.ID);
        }