public void CorrectTypeTestProvider(string type) { Mock <IChecklistRepo> mock = new Mock <IChecklistRepo>(); mock.Setup(p => p.GetQuestions(type)).Returns(ls); ChecklistProvider cp = new ChecklistProvider(mock.Object); List <Questions> result = cp.QuestionsProvider(type); Assert.AreEqual(2, result.Count); }
public void QuestionsProvider_ValidInput_OkRequest(string type) { Mock <IChecklistRepo> mock = new Mock <IChecklistRepo>(); mock.Setup(p => p.GetQuestions(type)).Returns(l1); ChecklistProvider cp = new ChecklistProvider(mock.Object); List <Questions> result = cp.QuestionsProvider(type); Assert.AreEqual(3, result.Count); }
public void WrongTypeTestProvider(string type) { try { Mock <IChecklistRepo> mock = new Mock <IChecklistRepo>(); mock.Setup(p => p.GetQuestions(type)).Returns(ls); ChecklistProvider cp = new ChecklistProvider(mock.Object); List <Questions> result = cp.QuestionsProvider(type); Assert.AreEqual(2, result.Count); } catch (Exception e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } }
public void GetQuestions_InvalidInput_ReturnBadRequest(string a) { try { string type = null; Mock <IChecklistRepo> mock = new Mock <IChecklistRepo>(); mock.Setup(p => p.GetQuestions(type)).Returns(l2); ChecklistProvider cp = new ChecklistProvider(mock.Object); List <Questions> result = cp.QuestionsProvider(type); Assert.AreEqual(0, result.Count); } catch (Exception e) { Assert.AreEqual("Object reference not set to an instance of an object.", e.Message); } }
public IActionResult Get(string auditType) { try { ChecklistProvider obj = new ChecklistProvider(); var list = obj.QuestionsProvider(auditType); if (list != null) { return(Ok(list)); } } catch (Exception) { return(Ok("EXception from AuditChecklist")); } return(BadRequest("No input or Wrong Input")); }
public IActionResult Get(string auditType) { _log4net.Info(" AuditChecklistController Http GET request called"); try { ChecklistProvider obj = new ChecklistProvider(); var list = obj.QuestionsProvider(auditType); if (list != null) { return(Ok(list)); } } catch (Exception) { _log4net.Info("Exception from AuditChecklist"); return(Ok("EXception from AuditChecklist")); } return(BadRequest("No input or Wrong Input")); }
public IActionResult Checklist(AuditDetail audittype) { try { _log4net.Info(" Http POST request " + nameof(Checklist) + " method called"); string Token = HttpContext.Request.Cookies["Token"]; if (string.IsNullOrEmpty(Token)) { ViewBag.Message = "Please Login"; return(View("Login")); } List <ChecklistQuestions> listOfQuestions = new List <ChecklistQuestions>(); ChecklistProvider checklistProvider = new ChecklistProvider(config); listOfQuestions = checklistProvider.GetQuestions(audittype.Type, Token); return(View(listOfQuestions)); } catch (Exception e) { _log4net.Error("Error From POST " + nameof(Checklist) + " Error Message: " + e.Message); return(View("Error")); } }