public void ApproveParticipantFailTest() { //Arrange int testParticipantId = 2; _repoWrapper.Setup(x => x.Participant.FindByCondition(It.IsAny <Expression <Func <Participant, bool> > >())) .Returns(new List <Participant> { new Participant { ID = 2, ParticipantStatusId = 3, EventId = 1, UserId = "abc-2" }, }.AsQueryable()); _repoWrapper.Setup(x => x.ParticipantStatus.FindByCondition(It.IsAny <Expression <Func <ParticipantStatus, bool> > >())) .Returns(new List <ParticipantStatus> { new ParticipantStatus { ID = 2, ParticipantStatusName = "Статус" }, }.AsQueryable()); _repoWrapper.Setup(x => x.Participant.Update((It.IsAny <Participant>()))).Throws(new Exception()); //Act var actionsController = new ActionController(_userManager.Object, _repoWrapper.Object, _env.Object); var actionResult = actionsController.ApproveParticipant(testParticipantId); var codeResult = actionResult as StatusCodeResult; //Assert Assert.NotNull(actionResult); Assert.IsType <StatusCodeResult>(actionResult); Assert.Equal(500, codeResult.StatusCode); }
public async void ApproveParticipantFailTest() { //Arrange int participantId = 2; _actionManager.Setup(x => x.ApproveParticipantAsync(It.IsAny <int>())) .Throws(new Exception()); //Act var actionsController = new ActionController(_actionManager.Object, _mapper.Object); var actionResult = await actionsController.ApproveParticipant(participantId); var codeResult = actionResult as StatusCodeResult; //Assert Assert.NotNull(actionResult); Assert.IsType <StatusCodeResult>(actionResult); Assert.Equal(StatusCodes.Status500InternalServerError, codeResult?.StatusCode); }
public async void ApproveParticipantSuccessTest() { //Arrange int participantId = 2; _actionManager.Setup(x => x.ApproveParticipantAsync(It.IsAny <int>())) .ReturnsAsync(StatusCodes.Status200OK); //Act var actionsController = new ActionController(_actionManager.Object, _mapper.Object); var actionResult = await actionsController.ApproveParticipant(participantId); var codeResult = actionResult as StatusCodeResult; //Assert Assert.NotNull(actionResult); Assert.IsType <StatusCodeResult>(actionResult); Assert.Equal(StatusCodes.Status200OK, codeResult?.StatusCode); }