private async void BeUniqueByApiKeyHashed_Create_Not_Exists() { Mock <IApiKeyRepository> apiKeyRepository = new Mock <IApiKeyRepository>(); apiKeyRepository.Setup(x => x.ByApiKeyHashed(It.IsAny <string>())).Returns(Task.FromResult <ApiKey>(null)); var validator = new ApiApiKeyRequestModelValidator(apiKeyRepository.Object); await validator.ValidateCreateAsync(new ApiApiKeyRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.ApiKeyHashed, "A"); }
public async void UserId_Create_length() { Mock <IApiKeyRepository> apiKeyRepository = new Mock <IApiKeyRepository>(); apiKeyRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new ApiKey())); var validator = new ApiApiKeyRequestModelValidator(apiKeyRepository.Object); await validator.ValidateCreateAsync(new ApiApiKeyRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.UserId, new string('A', 51)); }