private async void BeUniqueByApiKeyHashed_Create_Exists() { Mock <IApiKeyRepository> apiKeyRepository = new Mock <IApiKeyRepository>(); apiKeyRepository.Setup(x => x.ByApiKeyHashed(It.IsAny <string>())).Returns(Task.FromResult <ApiKey>(new ApiKey())); var validator = new ApiApiKeyRequestModelValidator(apiKeyRepository.Object); await validator.ValidateCreateAsync(new ApiApiKeyRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.ApiKeyHashed, "A"); }
public async void UserId_Update_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.ValidateUpdateAsync(default(string), new ApiApiKeyRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.UserId, new string('A', 51)); }