public void TestInsertTblRegisteredStudents() { DataTable dt = new DataTable(); dt.Columns.Add("FirstName"); dt.Columns.Add("LastName"); dt.Columns.Add("ContactNumber"); dt.Columns.Add("EmailID"); dt.Columns.Add("StudentRollNo"); dt.Columns.Add("CollegeName"); dt.Rows.Add(); dt.Rows[dt.Rows.Count - 1][0] = "Karthik"; dt.Rows[dt.Rows.Count - 1][1] = "Patlolla"; dt.Rows[dt.Rows.Count - 1][2] = "9133793161"; dt.Rows[dt.Rows.Count - 1][3] = "*****@*****.**"; dt.Rows[dt.Rows.Count - 1][4] = "12234"; dt.Rows[dt.Rows.Count - 1][5] = "IITH"; //{ // CollegeDetails = null, // ContactNumber = "9133793161", // EmailID = "*****@*****.**", // FirstName = "Karthik", // LastName = "Patlolla", // StudentRollNumber = "12234", //}); var moqDBInstance = new Mock <EAT_DBContext>(); var moqDBset = new Mock <DbSet <RegisteredStudents> >(); var moqCheckStudents = new Mock <ICheckStudentExists>(); moqDBInstance.Setup(m => m.RegisteredStudents).Returns(moqDBset.Object); moqCheckStudents.Setup(x => x.CheckStudent(It.IsAny <string>())).Returns(true); EventRegistrationDAL eventRegistrationDal = new EventRegistrationDAL(moqCheckStudents.Object, moqDBInstance.Object); var studentDict = eventRegistrationDal.InsertTblRegisteredStudents(dt); moqDBset.Verify(m => m.Add(It.IsAny <RegisteredStudents>()), Times.Once); moqDBInstance.Verify(m => m.SaveChanges(), Times.Once); Assert.AreEqual(studentDict.Count, 1); }
public Dictionary <string, string> InsertTblRegisteredStudents(DataTable StudentRegistrationData, int EventID, string EventName) { EventRegistrationDAL eventRegistration = new EventRegistrationDAL(); Dictionary <String, String> returnData = new Dictionary <String, String>(); List <String> EmailList = new List <String>(); Dictionary <String, String> studentsInsertReturnValue = eventRegistration.InsertTblRegisteredStudents(StudentRegistrationData); foreach (var item in studentsInsertReturnValue.Keys) { if (studentsInsertReturnValue[item].Equals("Invalid Data")) { returnData.Add(item, studentsInsertReturnValue[item]); } else { EmailList.Add(item); } } if (EmailList.Count > 0) { var AttenddesInsertList = eventRegistration.InsertTblEventAttendees(EmailList, EventID); //if (AttenddesInsertList.Count > 0) //{ // _mailSend.SendRegistrationMail(AttenddesInsertList, EventID); // Debug.Print("Succesfully added data into Attendees Table"); //} //else //{ // Debug.Print("Could not insert data into Attendees Table"); //} } else { Debug.Print("Could not insert data into Registration Table"); } return(returnData); }
public List <String> InsertTblRegisteredStudents(DataTable StudentRegistrationData, int EventID, string EventName) { EventRegistrationDAL eventRegistration = new EventRegistrationDAL(); List <String> studentsInsertReturnValue = eventRegistration.InsertTblRegisteredStudents(StudentRegistrationData); if (studentsInsertReturnValue.Count > 0) { var AttenddesInsertList = eventRegistration.InsertTblEventAttendees(studentsInsertReturnValue, EventID); if (AttenddesInsertList.Count > 0) { _mailSend.SendRegistrationMail(AttenddesInsertList, EventID); Debug.Print("Succesfully added data into Attendees Table"); } else { Debug.Print("Could not insert data into Attendees Table"); } } else { Debug.Print("Could not insert data into Registration Table"); } return(studentsInsertReturnValue); }