public void TestUpdateInvitation() { Invitation invitation = GetNewInvitation(); DatabaseService databaseService = new DatabaseService(); InvitationService invitationService = new InvitationService(databaseService); invitationService.CreateServicedObject(ref invitation); UserService userService = new UserService(databaseService); User replacement = new User() { Name = "Replacement", LastName = "Test", Email = "*****@*****.**", Password = "******" }; userService.CreateServicedObject(ref replacement); replacement = userService.GetServicedObjectWhere("name = 'Replacement'"); Assert.AreEqual(user.Id, invitation.UserId); invitation.UserId = replacement.Id; invitationService.UpdateServicedObject(ref invitation); Assert.AreEqual(replacement.Id, invitation.UserId); invitationService.DeleteServicedObjectWhere($"user_id = {replacement.Id} and event_id = {_event.Id}"); userService.DeleteServicedObject(replacement); }
public void TestGetAllInvitations() { InvitationService invitationService = new InvitationService(new DatabaseService()); for (int i = 0; i < 10; i++) { Invitation invitation = GetNewInvitation(); invitationService.CreateServicedObject(ref invitation); } List <Invitation> invitations = invitationService.GetAllServicedObjectsWhere($"user_id = {user.Id}"); Assert.AreEqual(10, invitations.Count); invitationService.DeleteServicedObjectWhere($"user_id = {user.Id}"); }