public async void TagName_Update_null() { Mock <ITagRepository> tagRepository = new Mock <ITagRepository>(); tagRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Tag())); var validator = new ApiTagServerRequestModelValidator(tagRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiTagServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.TagName, null as string); }
public async void TagName_Create_length() { Mock <ITagRepository> tagRepository = new Mock <ITagRepository>(); tagRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Tag())); var validator = new ApiTagServerRequestModelValidator(tagRepository.Object); await validator.ValidateCreateAsync(new ApiTagServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.TagName, new string('A', 151)); }
public async void ExcerptPostId_Update_Invalid_Reference() { Mock <ITagRepository> tagRepository = new Mock <ITagRepository>(); tagRepository.Setup(x => x.PostByExcerptPostId(It.IsAny <int>())).Returns(Task.FromResult <Post>(null)); var validator = new ApiTagServerRequestModelValidator(tagRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiTagServerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.ExcerptPostId, 1); }