public void CorrectTypeController(string type) { Mock <IChecklistProvider> mock = new Mock <IChecklistProvider>(); mock.Setup(p => p.QuestionsProvider(type)).Returns(ls); AuditChecklistController cp = new AuditChecklistController(mock.Object); OkObjectResult result = cp.GetQuestions(type) as OkObjectResult; Assert.AreEqual(200, result.StatusCode); }
public void WrongTypeController(string type) { try { Mock <IChecklistProvider> mock = new Mock <IChecklistProvider>(); mock.Setup(p => p.QuestionsProvider(type)).Returns(ls); AuditChecklistController cp = new AuditChecklistController(mock.Object); OkObjectResult result = cp.GetQuestions(type) as OkObjectResult; Assert.AreEqual(200, result.StatusCode); } catch (Exception e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } }