public void AreCredentialsAlreadyInUseOnEmailUsedByModerator(CredentialsCheckDto credentials) { "Given that the nickname is not used by a pupil or a moderator" .x(() => { _moderatorService.Setup(_ => _.IsNicknameAlreadyInUse(It.IsAny <string>())) .Returns(false); _pupilService.Setup(_ => _.IsNicknameAlreadyInUse(It.IsAny <string>())) .Returns(false); }); "And that the email is not used by a pupil but used by a moderator" .x(() => { _moderatorService.Setup(_ => _.IsEmailAlreadyInUse(It.IsAny <string>())) .Returns(true); _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.Once); _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.AtMostOnce); }); }