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 TestGetJob() { Job exec = new Job("exec"); jobImpl.SaveJob(exec); Job result = jobImpl.GetJob(exec.Name); Assert.AreEqual(exec, result); // Cleanup jobImpl.DeleteJob(exec.Name); }