public PatientMonitor AddProductintoDatabase(PatientMonitor PatientMonitor) { using (ChatBotDBEntities entities = new ChatBotDBEntities()) { var entity = entities.PatientMonitors.Add(PatientMonitor); entities.SaveChanges(); return(entity); } }
bool IChatbot.PostNewMonitors(PatientMonitor newmod) { PhilipsDBEntities record = new PhilipsDBEntities(); var selected = record.PatientMonitors.FirstOrDefault((e) => e.Model.Equals(newmod.Model)); if (selected == null) { record.PatientMonitors.Add(newmod); record.SaveChanges(); return(true); } return(false); }
public HttpResponseMessage Post([FromBody] PatientMonitor data) { _monitorCrud = _con.Resolve <MonitorCrudContractsLib.IMonitorCrud>(); var entity = _monitorCrud.AddProductintoDatabase(data); if (entity == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Device is not added")); } else { return(Request.CreateResponse(HttpStatusCode.OK, "Product has been added successfully ")); } }
//It checks if there is any null in generated json public void Given_Patient_Id_When_GenerateVitalSignAsJson_Invoke_Then_Valid_Result_Asserted() { PatientMonitor m_patientMonitor = new PatientMonitor(); string m_actualValue = m_patientMonitor.GenerateVitalSignAsJson("PatientId_23"); string[] m_values = m_actualValue.Split(' '); //It checks there should be 8 entity in the json string Assert.AreEqual(8, m_values.Length); foreach (string value in m_values) { if (string.IsNullOrEmpty(value)) { Assert.Fail("Failed"); } } }
public void Given_InValid_Product_False_Value_Is_Returned() { PatientMonitor patientMonitor = new PatientMonitor { Name = "Avalon", Model = "FM60", Screen_Size = "LargeScreen", Portability = "-", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "HeavyWeight", Care_Stage = "Antepartum" }; bool expectedValue = MockChatbotRepository.PostNewMonitors(patientMonitor); bool actualValue = false; Assert.AreEqual(actualValue, expectedValue); }
public CategoryUnitTest() { question1 = new Question { Identifier = "Category", Question1 = "Based on which of these categories do you want to filter the monitors?", Option_1 = "ScreenSize", Option_2 = "Portability", Option_3 = "TouchScreen" }; question2 = new Question { Identifier = "Category/ScreenSize", Question1 = "Based on which of these categories do you want to filter the monitors??", Option_1 = "Small Screen", Option_2 = "Large Screen", Option_3 = "-" }; PatientMonitor1 = new PatientMonitor { Name = "Efficia", Model = "CM10", Screen_Size = "SmallScreen", Portability = "Portable", Touch_Screen = "TouchScreenDisabled", Use = "ICU", Location = "SemiUrban", Weight = "", Care_Stage = "-" }; PatientMonitor2 = new PatientMonitor { Name = "Efficia", Model = "CM12", Screen_Size = "LargeScreen", Portability = "Portable", Touch_Screen = "TouchScreenDisabled", Use = "ICU", Location = "SemiUrban", Weight = "", Care_Stage = "-" }; PatientMonitor3 = new PatientMonitor { Name = "Avalon", Model = "FM20", Screen_Size = "SmallScreen", Portability = "Portable", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "LightWeight", Care_Stage = "Antepartum" }; PatientMonitor4 = new PatientMonitor { Name = "Avalon", Model = "FM40", Screen_Size = "SmallScreen", Portability = "NonPortable", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "HeavyWeight", Care_Stage = "Antepartum" }; PatientMonitor5 = new PatientMonitor { Name = "Avalon", Model = "FM50", Screen_Size = "SmallScreen", Portability = "NonPortable", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "HeavyWeight", Care_Stage = "Intrapartum" }; MonitorsList.Add(PatientMonitor1); MonitorsList.Add(PatientMonitor2); MonitorsList.Add(PatientMonitor3); MonitorsList.Add(PatientMonitor4); MonitorsList.Add(PatientMonitor5); Moq.Mock <CategoryContractLib.ICategory> _mockCategory = new Moq.Mock <CategoryContractLib.ICategory>(); _mockCategory.Setup(mq => mq.GetCategories()).Returns(question1); _mockCategory.Setup(mq => mq.GetQuestion1(It.IsAny <string>())).Returns(question2); _mockCategory.Setup(mq => mq.GetSolution(It.IsAny <string>(), It.IsAny <string>())).Returns(MonitorsList); this.MockQuestionRepository = _mockCategory.Object; }
public void Given_Valid_Product_Add_Into_The_Database() { PatientMonitor patientMonitor = new PatientMonitor { Name = "Avalon", Model = "FM80", Screen_Size = "SmallScreen", Portability = "-", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "LightWeight", Care_Stage = "Antepartum" }; PatientMonitor patientMonitor1 = new PatientMonitor { Name = "Avalon", Model = "FM70", Screen_Size = "SmallScreen", Portability = "-", Touch_Screen = "TouchScreenEnabled", Use = "LabourCare", Location = "-", Weight = "LightWeight", Care_Stage = "Intrapartum" }; MockChatbotRepository.PostNewMonitors(patientMonitor1); MockChatbotRepository.PostNewMonitors(patientMonitor); int monitorCount = MockChatbotRepository.GetAllMonitors().Count; Assert.AreEqual(3, monitorCount); }
public void PostMonitors([FromBody] PatientMonitor newmod) { ChatbotContractLib.IChatbot chatbot; chatbot = _con.Resolve <ChatbotContractLib.IChatbot>(); chatbot.PostNewMonitors(newmod); }
public ChatbotUnitTest() { patientMonitors = new List <PatientMonitor>() { new PatientMonitor { Name = "Avalon", Model = "FM60", Screen_Size = "LargeScreen", Portability = "-", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "HeavyWeight", Care_Stage = "Antepartum" } }; questions = new List <Question>() { new Question { Identifier = "Category", Question1 = "Based on which of these categories do you want to filter the monitors?", Option_1 = "Screen Size", Option_2 = "Portability", Option_3 = "Touch Screen" } }; avalonMonitors = new List <PatientMonitor>() { new PatientMonitor { Name = "Avalon", Model = "FM20", Screen_Size = "SmallScreen", Portability = "Portable", Touch_Screen = "TouchScreenDisabled", Use = "LabourCare", Location = "-", Weight = "HeavyWeight", Care_Stage = "Antepartum" }, new PatientMonitor { Name = "Avalon", Model = "FM30", Screen_Size = "SmallScreen", Portability = "Portable", Touch_Screen = "TouchScreenEnabled", Use = "LabourCare", Location = "-", Weight = "LightWeight", Care_Stage = "Intrapartum" } }; intellivueMonitors = new List <PatientMonitor>() { new PatientMonitor { Name = "Intellivue", Model = "MX700", Screen_Size = "LargeScreen", Portability = "Portable", Touch_Screen = "TouchScreenDisabled", Use = "ICU", Location = "Urban", Weight = "-", Care_Stage = "-" }, new PatientMonitor { Name = "Intellivue", Model = "MX800", Screen_Size = "LargeScreen", Portability = "NonPortable", Touch_Screen = "TouchScreenEnabled", Use = "ICU", Location = "Urban", Weight = "-", Care_Stage = "-" } }; question = new Question { Identifier = "Category", Question1 = "Based on which of these categories do you want to filter the monitors?", Option_1 = "ScreenSize", Option_2 = "Portability", Option_3 = "TouchScreen" }; q2 = new Question { Identifier = "Initial/ICU", Question1 = "In what kind of an area is the hospital located?", Option_1 = "Urban", Option_2 = "SemiUrban", Option_3 = "-" }; q3 = new Question { Identifier = "Initial/ICU/Urban", Question1 = "Based on what property do you want to Filter the monitors?", Option_1 = "Portability", Option_2 = "Screen Size", Option_3 = "-" }; q1 = new Question { Identifier = "Initial", Question1 = "Where will the monitor be used?", Option_1 = "ICU", Option_2 = "Labour care", Option_3 = "-" }; q4 = new Question { Identifier = "Initial/ICU/Urban/Portability", Question1 = "Based on monitor portability, how do you want to filter the monitors?", Option_1 = "Portable", Option_2 = "NonPortable", Option_3 = "-" }; Moq.Mock <ChatbotContractLib.IChatbot> mock = new Moq.Mock <ChatbotContractLib.IChatbot>(); mock.Setup(mr => mr.GetAllMonitors()).Returns(patientMonitors); mock.Setup(mr => mr.GetAllQuestions()).Returns(questions); mock.Setup(mr => mr.GetInitialQuestion()).Returns(q1); mock.Setup(mr => mr.GetQ2(It.IsAny <string>())).Returns(q2); mock.Setup(mr => mr.GetQ3(It.IsAny <string>(), It.IsAny <string>())).Returns(q3); mock.Setup(mr => mr.GetQ4(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(q4); mock.Setup(mr => mr.GetICUSolution(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(intellivueMonitors); mock.Setup(mr => mr.GetAvalonSolution(It.IsAny <string>(), It.IsAny <string>())).Returns(avalonMonitors); mock.Setup(mr => mr.PostNewMonitors(It.IsAny <PatientMonitor>())).Returns((PatientMonitor pm) => { PatientMonitor patientMonitor = patientMonitors.Find(d => d.Model == pm.Model); if (patientMonitor == null) { patientMonitors.Add(pm); return(true); } return(false); } );// mock.Setup(mr => mr.DeleteMonitor(It.IsAny <string>())).Returns((string mon) => { PatientMonitor patientMonitor = patientMonitors.Find(d => d.Model == (mon).ToString()); if (patientMonitor != null) { patientMonitors.Remove(patientMonitor); return(true); } return(false); }); this.MockChatbotRepository = mock.Object; }