public void TestAddDeleteJob() { Employee homer = new Employee("homer", "simpson", "123456789", "*****@*****.**", Gender.MALE, Rank.E1); Job exec = new Job("exec"); // Neither object exists yet in db Assert.IsFalse(persImpl.AddJob(homer, exec)); // Add info and verify persistence persImpl.SavePerson(homer); jobImpl.SaveJob(exec); Assert.IsTrue(persImpl.AddJob(homer, exec)); // Now retrieve the objects and verify they contain the changes Employee emp = persImpl.GetEmployee(homer.FirstName, homer.LastName); Job job = jobImpl.GetJob(exec.Name); Assert.AreEqual(exec, emp.Jobs[0]); Assert.AreEqual(homer, job.Employees[0]); // Test Deleting by overwriting initial objects and verifying changes Assert.IsTrue(persImpl.DeleteJob(emp, job)); homer = persImpl.GetEmployee(homer.FirstName, homer.LastName); exec = jobImpl.GetJob(exec.Name); Assert.IsTrue(homer.Jobs.Count == 0 && exec.Employees.Count == 0); // Cleanup & Delete Assert.IsTrue(persImpl.DeletePerson(homer.FirstName, homer.LastName)); Assert.IsTrue(jobImpl.DeleteJob(exec.Name)); }
public void TestSaveDeleteJob() { Job exec = new Job("exec"); Assert.IsTrue(jobImpl.SaveJob(exec)); // False since it's now already in db Assert.IsFalse(jobImpl.SaveJob(exec)); // Cleanup & test delete Assert.IsTrue(jobImpl.DeleteJob(exec.Name)); }