Exemple #1
0
        public async void Name_Update_length()
        {
            Mock <IFileTypeRepository> fileTypeRepository = new Mock <IFileTypeRepository>();

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

            var validator = new ApiFileTypeRequestModelValidator(fileTypeRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiFileTypeRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 256));
        }
        public async void Name_Create_null()
        {
            Mock <IFileTypeRepository> fileTypeRepository = new Mock <IFileTypeRepository>();

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

            var validator = new ApiFileTypeRequestModelValidator(fileTypeRepository.Object);
            await validator.ValidateCreateAsync(new ApiFileTypeRequestModel());

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