public void CrudManagerCanReadAllApplications() { List <Applicant> entries = CrudManager.RetrieveAllApplications(); // Assertions Assert.NotNull(entries); Assert.Greater(entries.Count, 0); }
public void CrudManagerCanCreateValidApplication() { // Old int oldApplicantsCount = CrudManager.RetrieveAllApplications().Count; // Current Applicant applicantAdded = CreateApplication(); int currentApplicantsCount = CrudManager.RetrieveAllApplications().Count; // Assertions Assert.AreEqual(ApplicantToTest, applicantAdded); Assert.Greater(currentApplicantsCount, oldApplicantsCount); }
public void DeleteFromDatabase() { List <Applicant> applicantsToDelete = CrudManager .RetrieveAllApplications() .Where(a => a.Equals(ApplicantToTest) || a.Equals(ApplicantToTest_Edited)).ToList(); if (null != applicantsToDelete && applicantsToDelete.Count > 0) { foreach (Applicant a in applicantsToDelete) { if (null != a) { CrudManager.DeleteApplication(a); } } } }
public void CrudManagerCanDeleteValidEntry() { // Old int oldCount = CrudManager.RetrieveAllApplications().Count; // Current Applicant applicant = CreateApplication(); int currentCount = CrudManager.RetrieveAllApplications().Count; // Final CrudManager.DeleteApplication(applicant); List <Applicant> finalApplicants = CrudManager.RetrieveAllApplications(); int finalCount = finalApplicants.Count; // Assertions Assert.Less(oldCount, currentCount); Assert.Less(finalCount, currentCount); }
public void CrudManagerCanUpdateValidApplication() { // Old Applicant originalApplicant = CreateApplication(); int oldCount = CrudManager.RetrieveAllApplications().Count; // Current Applicant applicantToEdit = originalApplicant.CreateMemberwiseClone(); applicantToEdit.FirstName = "Uma"; applicantToEdit.MiddleName = "Karuna"; applicantToEdit.Surname = "Thurman"; CrudManager.UpdateApplication(originalApplicant, applicantToEdit); // Final List <Applicant> finalApplicants = CrudManager.RetrieveAllApplications(); int finalCount = finalApplicants.Count; // Assertions Assert.AreEqual(finalCount, oldCount); // The original remains in the database, just edited: Assert.False(finalApplicants.Contains(applicantToEdit)); Assert.True(finalApplicants.Contains(originalApplicant)); }