예제 #1
0
        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");
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }