コード例 #1
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);
        }
コード例 #2
0
        private async void BeUniqueByName_Update_Not_Exists()
        {
            Mock <IDepartmentRepository> departmentRepository = new Mock <IDepartmentRepository>();

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

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

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