public async void EmailHash_Update_length() { Mock <IUserRepository> userRepository = new Mock <IUserRepository>(); userRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new User())); var validator = new ApiUserRequestModelValidator(userRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiUserRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.EmailHash, new string('A', 41)); }
public async void DisplayName_Update_null() { Mock <IUserRepository> userRepository = new Mock <IUserRepository>(); userRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new User())); var validator = new ApiUserRequestModelValidator(userRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiUserRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.DisplayName, null as string); }
public async void WebsiteUrl_Create_length() { Mock <IUserRepository> userRepository = new Mock <IUserRepository>(); userRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new User())); var validator = new ApiUserRequestModelValidator(userRepository.Object); await validator.ValidateCreateAsync(new ApiUserRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.WebsiteUrl, new string('A', 201)); }
private async void BeUniqueByUsername_Update_Exists() { Mock <IUserRepository> userRepository = new Mock <IUserRepository>(); userRepository.Setup(x => x.ByUsername(It.IsAny <string>())).Returns(Task.FromResult <User>(new User())); var validator = new ApiUserRequestModelValidator(userRepository.Object); await validator.ValidateUpdateAsync(default(string), new ApiUserRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Username, "A"); }
public async void Privacy_Create_null() { Mock <IUserRepository> userRepository = new Mock <IUserRepository>(); userRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new User())); var validator = new ApiUserRequestModelValidator(userRepository.Object); await validator.ValidateCreateAsync(new ApiUserRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Privacy, null as string); }
public async void LocationLocationId_Update_Invalid_Reference() { Mock <IUserRepository> userRepository = new Mock <IUserRepository>(); userRepository.Setup(x => x.LocationByLocationLocationId(It.IsAny <int>())).Returns(Task.FromResult <Location>(null)); var validator = new ApiUserRequestModelValidator(userRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiUserRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.LocationLocationId, 1); }