Exemple #1
0
        public async Task ChangeStatusToRejectedSuccessTest()
        {
            //Arrange
            int participantId     = 1;
            int participantStatus = 3;
            var participant       = new Participant {
                ID = 1, ParticipantStatusId = 2, EventId = 1, UserId = "abc-1"
            };
            var testEvent = new Event {
                ID = 1, EventStatusID = 1
            };

            _repoWrapper.Setup(x => x.Participant.GetFirstAsync(It.IsAny <Expression <Func <Participant, bool> > >(), null))
            .ReturnsAsync(participant);
            _repoWrapper.Setup(x => x.Event.GetFirstAsync(It.IsAny <Expression <Func <Event, bool> > >(), null)).ReturnsAsync(testEvent);
            _participantStatusManager.Setup(x => x.GetStatusIdAsync(It.IsAny <string>()))
            .ReturnsAsync(participantStatus);
            //Act
            var participantManager = new ParticipantManager(_repoWrapper.Object, _eventStatusManager.Object, _participantStatusManager.Object);
            var methodResult       = await participantManager.ChangeStatusToRejectedAsync(participantId);

            //Assert
            _repoWrapper.Verify(r => r.Participant.Update(It.IsAny <Participant>()), Times.Once());
            _repoWrapper.Verify(r => r.SaveAsync(), Times.Once());
            Assert.Equal(StatusCodes.Status200OK, methodResult);
        }
Exemple #2
0
        public async Task ChangeStatusToRejectedFailTest()
        {
            //Arrange
            int participantId     = 1;
            int participantStatus = 3;

            _repoWrapper.Setup(x => x.Participant.GetFirstAsync(It.IsAny <Expression <Func <Participant, bool> > >(), null))
            .ThrowsAsync(new Exception());
            _participantStatusManager.Setup(x => x.GetStatusIdAsync(It.IsAny <string>()))
            .ReturnsAsync(participantStatus);
            //Act
            var participantManager = new ParticipantManager(_repoWrapper.Object, _eventStatusManager.Object, _participantStatusManager.Object);
            var methodResult       = await participantManager.ChangeStatusToRejectedAsync(participantId);

            //Assert
            Assert.Equal(StatusCodes.Status400BadRequest, methodResult);
        }
Exemple #3
0
        public async Task ChangeStatusToRejectedFailStatusidTest()
        {
            //Arrange
            int participantId     = 1;
            int participantStatus = 3;
            var participant       = new Participant {
                ID = 1, ParticipantStatusId = 3, EventId = 1, UserId = "abc-1"
            };
            var testEvent = new Event {
                ID = 1, EventStatusID = 1
            };

            _repoWrapper.Setup(x => x.Participant.GetFirstAsync(It.IsAny <Expression <Func <Participant, bool> > >(), null))
            .ReturnsAsync(participant);
            _repoWrapper.Setup(x => x.Event.GetFirstAsync(It.IsAny <Expression <Func <Event, bool> > >(), null)).ReturnsAsync(testEvent);
            _participantStatusManager.Setup(x => x.GetStatusIdAsync(It.IsAny <string>()))
            .ReturnsAsync(participantStatus);
            //Act
            var participantManager = new ParticipantManager(_repoWrapper.Object, _eventStatusManager.Object, _participantStatusManager.Object);
            var methodResult       = await participantManager.ChangeStatusToRejectedAsync(participantId);

            //Assert
            Assert.Equal(StatusCodes.Status409Conflict, methodResult);
        }