Esempio n. 1
0
        public void CrudManagerCanReadAllApplications()
        {
            List <Applicant> entries = CrudManager.RetrieveAllApplications();

            // Assertions
            Assert.NotNull(entries);
            Assert.Greater(entries.Count, 0);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        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);
                    }
                }
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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));
        }