public void TestCreate_EmptyParameter() { InventoryPartView expectedObject = MockObjectsUtil.GetMockInventoryPartView(1); List <InventoryPartView> data = new List <InventoryPartView>() { MockObjectsUtil.GetMockInventoryPartView(1) }; Mock <InventoryPartManager> mockManager = new Mock <InventoryPartManager>(); mockManager.Setup(x => x.InsertInventoryPart(It.IsAny <InventoryPartView>())); InventoryPartsController controller = new InventoryPartsController(mockManager.Object); ViewResult result = controller.Create() as ViewResult; Assert.IsNotNull(result); Assert.IsNull(result.Model); }
public void TestCreate_WithParameters() { 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.InsertInventoryPart(It.IsAny <InventoryPartView>())); InventoryPartsController controller = new InventoryPartsController(mockManager.Object); ViewResult result = controller.Create(inputObject) as ViewResult; Assert.IsNull(result); }