public void Pass_GetResponseControllerTest(string type) { Mock <ISeverityProvider> mock = new Mock <ISeverityProvider>(); AuditResponse rp = new AuditResponse(); AuditRequest req = new AuditRequest() { Auditdetails = new AuditDetail() { Type = type, questions = new Questions() { Question1 = true, Question2 = false, Question3 = false, Question4 = false, Question5 = false } } }; mock.Setup(p => p.SeverityResponse(req)).Returns(rp); AuditSeverityController cp = new AuditSeverityController(mock.Object); OkObjectResult result = cp.Post(req) as OkObjectResult; Assert.AreEqual(200, result.StatusCode); }
public void Fail_GetResponseControllerTest(string type) { try { Mock <ISeverityProvider> mock = new Mock <ISeverityProvider>(); AuditResponse rp = new AuditResponse(); AuditRequest req = new AuditRequest() { Auditdetails = new AuditDetail() { Type = type, questions = new Questions() { Question1 = true, Question2 = false, Question3 = false, Question4 = false, Question5 = false } } }; mock.Setup(p => p.SeverityResponse(req)).Returns(rp); AuditSeverityController cp = new AuditSeverityController(mock.Object); OkObjectResult result = cp.Post(req) as OkObjectResult; Assert.AreEqual(200, result.StatusCode); } catch (Exception e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } }