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

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

            Assert.IsNull(result);
        }
        public void TestDetails_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.GetInventoryPartFromId(It.IsAny <int?>())).Returns(expectedObject);
            InventoryPartsController controller = new InventoryPartsController(mockManager.Object);
            HttpStatusCodeResult     result     = controller.Details(null) as HttpStatusCodeResult;

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

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

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