Exemple #1
0
        public void TestCreateGetParticipantExchangeVisitorDTOByIdQuery()
        {
            var project = new Project
            {
                ProjectId = 100
            };
            var participant = new Participant
            {
                ParticipantId = 2,
                ProjectId     = project.ProjectId,
                Project       = project
            };

            var visitor = new ParticipantExchangeVisitor
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
            };

            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.ParticipantExchangeVisitors.Add(visitor);
            Action <ParticipantExchangeVisitorDTO> tester = (result) =>
            {
                Assert.IsNotNull(result);
                Assert.AreEqual(project.ProjectId, result.ProjectId);
                Assert.AreEqual(participant.ParticipantId, result.ParticipantId);
            };
            var queryResult = ParticipantExchangeVisitorQueries.CreateGetParticipantExchangeVisitorDTOByIdQuery(context, project.ProjectId, participant.ParticipantId).ToList();

            Assert.AreEqual(1, queryResult.Count());
            tester(queryResult.First());
        }
Exemple #2
0
        public void TestCreateGetParticipantExchangeVisitorDTOByIdQuery_InvalidProjectId()
        {
            var project = new Project
            {
                ProjectId = 100
            };
            var participant = new Participant
            {
                ParticipantId = 2,
                ProjectId     = project.ProjectId,
                Project       = project
            };

            var visitor = new ParticipantExchangeVisitor
            {
                ParticipantId = participant.ParticipantId,
                Participant   = participant,
            };

            context.Projects.Add(project);
            context.Participants.Add(participant);
            context.ParticipantExchangeVisitors.Add(visitor);
            var queryResult = ParticipantExchangeVisitorQueries.CreateGetParticipantExchangeVisitorDTOByIdQuery(context, project.ProjectId, participant.ParticipantId).ToList();

            Assert.AreEqual(1, queryResult.Count());

            queryResult = ParticipantExchangeVisitorQueries.CreateGetParticipantExchangeVisitorDTOByIdQuery(context, project.ProjectId + 1, participant.ParticipantId).ToList();
            Assert.AreEqual(0, queryResult.Count());
        }
        /// <summary>
        /// Returns a participantExchangeVisitors asyncronously
        /// </summary>
        /// <param name="participantId">The participant id to lookup</param>
        /// <returns>The participantExchangeVisitors</returns>
        public Task <ParticipantExchangeVisitorDTO> GetParticipantExchangeVisitorByIdAsync(int projectId, int participantId)
        {
            var participantExchangeVisitor = ParticipantExchangeVisitorQueries.CreateGetParticipantExchangeVisitorDTOByIdQuery(this.Context, projectId, participantId).FirstOrDefaultAsync();

            this.logger.Trace("Retrieved participantExchangeVisitor by id [{0}].", participantId);
            return(participantExchangeVisitor);
        }