Пример #1
0
        public async void EmailHash_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.EmailHash, new string('A', 41));
        }
        private async void BeUniqueByUsername_Create_Not_Exists()
        {
            Mock <IUserRepository> userRepository = new Mock <IUserRepository>();

            userRepository.Setup(x => x.ByUsername(It.IsAny <string>())).Returns(Task.FromResult <User>(null));
            var validator = new ApiUserRequestModelValidator(userRepository.Object);

            await validator.ValidateCreateAsync(new ApiUserRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Username, "A");
        }
Пример #3
0
        public async void DisplayName_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.DisplayName, null as string);
        }
        public async void LocationLocationId_Create_Valid_Reference()
        {
            Mock <IUserRepository> userRepository = new Mock <IUserRepository>();

            userRepository.Setup(x => x.LocationByLocationLocationId(It.IsAny <int>())).Returns(Task.FromResult <Location>(new Location()));

            var validator = new ApiUserRequestModelValidator(userRepository.Object);
            await validator.ValidateCreateAsync(new ApiUserRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.LocationLocationId, 1);
        }