public void UpdateSchool() { // Setup var schoolRepository = new SchoolRepository(SchoolMachineContext); var newSchool = new School { Name = "Test School 2" }; schoolRepository.CreateSchool(newSchool).Wait(); var savedSchool = schoolRepository.GetSchoolById(newSchool.Id).Result; Assert.IsNotNull(savedSchool, string.Format("School {0} was not saved in the database", newSchool.Id)); Assert.IsTrue(savedSchool.Name == newSchool.Name, string.Format("School({0}).Name was not saved in the database", newSchool.Id)); // Test Logic newSchool.Name = "Test School 2 - Modified"; schoolRepository.UpdateSchool(savedSchool, newSchool).Wait(); // Assertions var retrievedSchool = schoolRepository.GetSchoolById(savedSchool.Id).Result; Assert.IsFalse(retrievedSchool.IsEmptyObject(), string.Format("Updated school({0}) was not retrieved from the database", newSchool.Id)); Assert.IsTrue(retrievedSchool.Name == newSchool.Name, string.Format("School({0}).Name was not updated in the database", newSchool.Id)); // Teardown schoolRepository.DeleteSchool(savedSchool).Wait(); var shouldBeDeletedSchool = schoolRepository.GetSchoolById(newSchool.Id).Result; Assert.IsTrue(shouldBeDeletedSchool.IsEmptyObject(), string.Format("School({0}) was not deleted from the database", newSchool.Id)); }
public void DeleteValidSchool() { School school = new School { name = "SMK", id = "001" }; repo.InsertSchool(school); repo.DeleteSchool(school.id); int doc = repo.countSchoolByName(school.name); Assert.Equal(doc, 0); }