コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }