Пример #1
0
        public async void GroupName_Create_length()
        {
            Mock <IDepartmentRepository> departmentRepository = new Mock <IDepartmentRepository>();

            departmentRepository.Setup(x => x.Get(It.IsAny <short>())).Returns(Task.FromResult(new Department()));

            var validator = new ApiDepartmentRequestModelValidator(departmentRepository.Object);
            await validator.ValidateCreateAsync(new ApiDepartmentRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.GroupName, new string('A', 51));
        }
Пример #2
0
        public async void Name_Update_null()
        {
            Mock <IDepartmentRepository> departmentRepository = new Mock <IDepartmentRepository>();

            departmentRepository.Setup(x => x.Get(It.IsAny <short>())).Returns(Task.FromResult(new Department()));

            var validator = new ApiDepartmentRequestModelValidator(departmentRepository.Object);
            await validator.ValidateUpdateAsync(default(short), new ApiDepartmentRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }
Пример #3
0
        private async void BeUniqueByName_Update_Exists()
        {
            Mock <IDepartmentRepository> departmentRepository = new Mock <IDepartmentRepository>();

            departmentRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Department>(new Department()));
            var validator = new ApiDepartmentRequestModelValidator(departmentRepository.Object);

            await validator.ValidateUpdateAsync(default(short), new ApiDepartmentRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, "A");
        }