public ActionResult <CredentialsCheckDto> AreIdentifiersAlreadyInUse( [FromQuery, SwaggerParameter("Credentials to check")] CredentialsCheckDto credentials) { return(Ok( _authenticationService.AreCredentialsAlreadyInUse(credentials))); }
public void AreCredentialsAlreadyInUseOnNicknameUsedByPupil(CredentialsCheckDto credentials) { "Given that the nickname is not used by a moderator but used by a pupil" .x(() => { _moderatorService.Setup(_ => _.IsNicknameAlreadyInUse(It.IsAny <string>())) .Returns(false); _pupilService.Setup(_ => _.IsNicknameAlreadyInUse(It.IsAny <string>())) .Returns(true); }); "And that the email is not used by a pupil or a moderator" .x(() => { _moderatorService.Setup(_ => _.IsEmailAlreadyInUse(It.IsAny <string>())) .Returns(false); _pupilService.Setup(_ => _.IsEmailAlreadyInUse(It.IsAny <string>())) .Returns(false); }); "And credentials to be checked" .x(() => credentials = _fixture.Create <CredentialsCheckDto>()); "When the user checks if the credentials are in use" .x(() => credentials = _authenticationService.AreCredentialsAlreadyInUse(credentials)); "Then the AreUnique flag should be false" .x(() => credentials.AreUnique.Should() .BeFalse()); "And both nickname and email should have been checked in both user services" .x(() => { // Moderator service _moderatorService.Verify(_ => _.IsEmailAlreadyInUse(It.IsAny <string>()), Times.AtMostOnce); _moderatorService.Verify(_ => _.IsNicknameAlreadyInUse(It.IsAny <string>()), Times.AtMostOnce); // Pupil service _pupilService.Verify(_ => _.IsEmailAlreadyInUse(It.IsAny <string>()), Times.AtMostOnce); _pupilService.Verify(_ => _.IsNicknameAlreadyInUse(It.IsAny <string>()), Times.Once); }); }