public async Task ChangeStatusToApprovedFailTest() { //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.ChangeStatusToApprovedAsync(participantId); //Assert Assert.Equal(StatusCodes.Status400BadRequest, methodResult); }
public async Task ChangeStatusToApprovedSuccessTest() { //Arrange int participantId = 1; int participantStatus = 3; _repoWrapper.Setup(x => x.Participant.GetFirstAsync(It.IsAny <Expression <Func <Participant, bool> > >(), null)) .ReturnsAsync( new Participant { ID = 1, ParticipantStatusId = 3, EventId = 1, UserId = "abc-1" } ); _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.ChangeStatusToApprovedAsync(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); }