public async System.Threading.Tasks.Task AddProjectAttendant_GivenExistingProjectIdAndAttendantIds_ShouldAddAttendantToProject()
        {
            var parameters = new PersonInProjectParameterDto
            {
                ProjectId    = Guid.NewGuid(),
                AttendantIds = new Guid[] { Guid.NewGuid() }
            };

            mockProjectRepository.Setup(x => x.GetSingleByCondition(It.IsAny <Expression <Func <Project, bool> > >()))
            .ReturnsAsync(mockProject);
            mockPersonRepository.Setup(x => x.GetSingleByCondition(It.IsAny <Expression <Func <Person, bool> > >()))
            .ReturnsAsync(mockPerson);
            mockPersonInProjectRepository.Setup(s => s.Create(It.IsAny <Domain.Entities.PersonInProject>()))
            .Returns(System.Threading.Tasks.Task.CompletedTask);
            mockPersonInProjectRepository.Setup(s => s.SaveChanges())
            .ReturnsAsync(true);

            var personInProjectService = new PersonInProjectService(mapper,
                                                                    mockPersonInProjectRepository.Object,
                                                                    mockPersonRepository.Object,
                                                                    mockProjectRepository.Object);

            var result = await personInProjectService.AddProjectAttendant(parameters);

            mockProjectRepository.Verify(v => v.GetSingleByCondition(It.IsAny <Expression <Func <Project, bool> > >()), Times.Once);
            mockPersonRepository.Verify(v => v.GetSingleByCondition(It.IsAny <Expression <Func <Person, bool> > >()), Times.AtLeastOnce);
            mockPersonInProjectRepository.Verify(v => v.SaveChanges(), Times.Once);

            Assert.IsTrue(result);
        }
        public async System.Threading.Tasks.Task GetProjectsWherePersonIsAttendant_ThereIsNoProjectsForTheGivenAttendant_ShouldReturnNull()
        {
            mockPersonInProjectRepository.Setup(x => x.GetProjectsByPersonWithProjectData(It.IsAny <Guid>()))
            .Returns(System.Threading.Tasks.Task.FromResult <IEnumerable <PersonInProject> >(null));

            var personInProjectService = new PersonInProjectService(mapper,
                                                                    mockPersonInProjectRepository.Object,
                                                                    mockPersonRepository.Object,
                                                                    mockProjectRepository.Object);

            var result = await personInProjectService.GetProjectsWherePersonIsAttendant(It.IsAny <Guid>());

            Assert.IsTrue(!result.Any());
        }
        public async System.Threading.Tasks.Task GetProjectsWherePersonIsAttendant_ThereIsProjectsForTheGivenAttendant_ShouldReturnProjects()
        {
            mockPersonInProjectRepository.Setup(x => x.GetProjectsByPersonWithProjectData(It.IsAny <Guid>()))
            .Returns(System.Threading.Tasks.Task.FromResult(GetPersonInProjects().Where(x => x.PersonId == mockPersonId)));

            var personInProjectService = new PersonInProjectService(mapper,
                                                                    mockPersonInProjectRepository.Object,
                                                                    mockPersonRepository.Object,
                                                                    mockProjectRepository.Object);

            var result = await personInProjectService.GetProjectsWherePersonIsAttendant(mockPersonId);

            Assert.IsTrue(result.Any());
            Assert.AreEqual(GetPersonInProjects().Count(x => x.PersonId == mockPersonId), result.Count());
        }
        public async System.Threading.Tasks.Task GetProjectAttendants_ThereIsntAttendantsInTheProject_ShouldReturnEmptyList()
        {
            mockPersonInProjectRepository.Setup(x => x.GetProjectAttendants(It.IsAny <Guid>()))
            .Returns(
                System.Threading.Tasks.Task.FromResult <IEnumerable <PersonInProject> >(null)
                );

            var personInProjectService = new PersonInProjectService(mapper,
                                                                    mockPersonInProjectRepository.Object,
                                                                    mockPersonRepository.Object,
                                                                    mockProjectRepository.Object);

            var result = await personInProjectService.GetProjectAttendants(mockProjedtId);

            Assert.IsTrue(!result.Any());
        }
        public async System.Threading.Tasks.Task RemoveProjectAttendant_TheAttendantDoesNotExists_ShouldReturnFalse()
        {
            var parameters = new PersonInProjectParameterDto
            {
                ProjectId    = Guid.NewGuid(),
                AttendantIds = new Guid[] { Guid.NewGuid() }
            };

            mockPersonInProjectRepository.Setup(x => x.GetSingleByCondition(It.IsAny <Expression <Func <PersonInProject, bool> > >()))
            .Returns(System.Threading.Tasks.Task.FromResult <PersonInProject>(null));
            mockPersonInProjectRepository.Setup(x => x.SaveChanges())
            .ReturnsAsync(false);

            var personInProjectService = new PersonInProjectService(mapper,
                                                                    mockPersonInProjectRepository.Object,
                                                                    mockPersonRepository.Object,
                                                                    mockProjectRepository.Object);

            var result = await personInProjectService.RemoveProjectAttendant(parameters);

            Assert.IsFalse(result);
        }
        public async System.Threading.Tasks.Task AddProjectAttendant_GivenAnUnexistingProjectId_ShouldntAddNewAttendantAndReturnFalse()
        {
            var parameters = new PersonInProjectParameterDto
            {
                ProjectId    = Guid.NewGuid(),
                AttendantIds = new Guid[] { Guid.NewGuid() }
            };

            mockProjectRepository.Setup(x => x.GetSingleByCondition(It.IsAny <Expression <Func <Project, bool> > >()))
            .Returns(System.Threading.Tasks.Task.FromResult <Project>(null));


            var personInProjectService = new PersonInProjectService(mapper,
                                                                    mockPersonInProjectRepository.Object,
                                                                    mockPersonRepository.Object,
                                                                    mockProjectRepository.Object);

            var result = await personInProjectService.AddProjectAttendant(parameters);

            mockProjectRepository.Verify(v => v.GetSingleByCondition(It.IsAny <Expression <Func <Project, bool> > >()), Times.Once);

            Assert.IsFalse(result);
        }