示例#1
0
        public async void Name_Update_length()
        {
            Mock <ISpeciesRepository> speciesRepository = new Mock <ISpeciesRepository>();

            speciesRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Species()));

            var validator = new ApiSpeciesRequestModelValidator(speciesRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSpeciesRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
示例#2
0
        public async void Name_Create_null()
        {
            Mock <ISpeciesRepository> speciesRepository = new Mock <ISpeciesRepository>();

            speciesRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Species()));

            var validator = new ApiSpeciesRequestModelValidator(speciesRepository.Object);
            await validator.ValidateCreateAsync(new ApiSpeciesRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }