public void AddCollaboratorTest() { var expectedCollaborator = GetNewMockCollaborator(user.UserId, expenseStory.ExpenseStoryId); collaboratorMgr.AddCollaborator(expectedCollaborator); var actualCollaborator = dataContext.Collaborator.FirstOrDefault(c => c.CollaboratorId == expectedCollaborator.CollaboratorId); Assert.IsNotNull(actualCollaborator, "Collaborator should not be null"); Assert.AreEqual(actualCollaborator.CollaboratorId, expectedCollaborator.CollaboratorId); Assert.AreEqual(actualCollaborator.GetHashCode(), expectedCollaborator.GetHashCode(), "actual and expected collaborator hash code should be equal"); }
public void GetAllCollaboratorsTest() { var expenseStory1 = GetNewMockPersonalExpenseStory(user.UserId); var collaborator1 = GetNewMockCollaborator(user.UserId, expenseStory1.ExpenseStoryId); var collaborator2 = GetNewMockCollaborator(user.UserId, expenseStory1.ExpenseStoryId); var collaborator3 = GetNewMockCollaborator(user.UserId, expenseStory1.ExpenseStoryId); var collaboratorMgr = new CollaboratorManager(new CollaboratorRepository(dbFactory), unitOfWork); var expenseStoryRepository = new ExpenseStoryRepository(dbFactory); new ExpenseStoryManager(expenseStoryRepository, unitOfWork, new ExpenseManager(new ExpenseRepository(dbFactory), unitOfWork), new CollaboratorManager(new CollaboratorRepository(dbFactory), unitOfWork)).AddExpenseStory(expenseStory1); var expectedCollaboratorsCount = 3; collaboratorMgr.AddCollaborator(collaborator1); collaboratorMgr.AddCollaborator(collaborator2); collaboratorMgr.AddCollaborator(collaborator3); var actualCollaboratorsCount = collaboratorMgr.GetAllCollaborators(expenseStory1.ExpenseStoryId).Count(); Assert.AreEqual(expectedCollaboratorsCount, actualCollaboratorsCount); }
public void DeleteCollaboratorTest() { var expenseStory1 = GetNewMockPersonalExpenseStory(user.UserId); var collaborator1 = GetNewMockCollaborator(user.UserId, expenseStory1.ExpenseStoryId); var collaboratorMgr = new CollaboratorManager(new CollaboratorRepository(dbFactory), unitOfWork); var expenseStoryRepository = new ExpenseStoryRepository(dbFactory); new ExpenseStoryManager(expenseStoryRepository, unitOfWork, new ExpenseManager(new ExpenseRepository(dbFactory), unitOfWork), new CollaboratorManager(new CollaboratorRepository(dbFactory), unitOfWork)).AddExpenseStory(expenseStory1); collaboratorMgr.AddCollaborator(collaborator1); collaboratorMgr.DeleteCollaborator(collaborator1.CollaboratorId); var isCollaboratorExists = dataContext.Collaborator.Any(c => c.CollaboratorId == collaborator1.CollaboratorId); Assert.IsFalse(isCollaboratorExists); }