public async void BadConfirmPassword() { // Triple A // Arrange Mock <IParticipantsRepository> mockRepo = new Mock <IParticipantsRepository>(); Mock <JWTSettings> mockJWT = new Mock <JWTSettings>(); ParticipantsController controller = new ParticipantsController(mockRepo.Object, mockJWT.Object); var model = new ParticipantDto { Login = "******", Password = "******", ConfirmPassword = "******", Participant_Type = ParticipantType.Doctor }; //ACT var result = await controller.PostParticipant(model); //ASSERT Assert.IsType <StatusCodeResult>(result.Result); }
public async void InvalidModelTest() { // Triple A // Arrange Mock <IParticipantsRepository> mockRepo = new Mock <IParticipantsRepository>(); Mock <JWTSettings> mockJWT = new Mock <JWTSettings>(); Mock <IMapper> mockMapper = new Mock <IMapper>(); ParticipantsController controller = new ParticipantsController(mockRepo.Object, mockJWT.Object); controller.ModelState.AddModelError("Login", "Required"); // need to manually simulate the model state error because the model state validation is only triggered during runtime. var model = new ParticipantDto { Password = "******", ConfirmPassword = "******", Participant_Type = ParticipantType.Doctor }; //ACT ActionResult <ParticipantDto> result = await controller.PostParticipant(model); //ASSERT Assert.IsType <BadRequestObjectResult>(result.Result); }