예제 #1
0
        private async void BeUniqueByName_Update_Exists()
        {
            Mock <IUserRoleRepository> userRoleRepository = new Mock <IUserRoleRepository>();

            userRoleRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <UserRole>(new UserRole()));
            var validator = new ApiUserRoleRequestModelValidator(userRoleRepository.Object);

            await validator.ValidateUpdateAsync(default(string), new ApiUserRoleRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, "A");
        }
예제 #2
0
        public async void Name_Update_length()
        {
            Mock <IUserRoleRepository> userRoleRepository = new Mock <IUserRoleRepository>();

            userRoleRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new UserRole()));

            var validator = new ApiUserRoleRequestModelValidator(userRoleRepository.Object);
            await validator.ValidateUpdateAsync(default(string), new ApiUserRoleRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 201));
        }