Example #1
0
        public async void Name_Update_length()
        {
            Mock <ILinkStatusRepository> linkStatusRepository = new Mock <ILinkStatusRepository>();

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

            var validator = new ApiLinkStatusRequestModelValidator(linkStatusRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiLinkStatusRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
Example #2
0
        private async void BeUniqueByName_Create_Exists()
        {
            Mock <ILinkStatusRepository> linkStatusRepository = new Mock <ILinkStatusRepository>();

            linkStatusRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <LinkStatus>(new LinkStatus()));
            var validator = new ApiLinkStatusRequestModelValidator(linkStatusRepository.Object);

            await validator.ValidateCreateAsync(new ApiLinkStatusRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, "A");
        }
Example #3
0
        public async void Name_Create_null()
        {
            Mock <ILinkStatusRepository> linkStatusRepository = new Mock <ILinkStatusRepository>();

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

            var validator = new ApiLinkStatusRequestModelValidator(linkStatusRepository.Object);
            await validator.ValidateCreateAsync(new ApiLinkStatusRequestModel());

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