コード例 #1
0
        private async void BeUniqueByName_Update_Not_Exists()
        {
            Mock <ILifecycleRepository> lifecycleRepository = new Mock <ILifecycleRepository>();

            lifecycleRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Lifecycle>(null));
            var validator = new ApiLifecycleRequestModelValidator(lifecycleRepository.Object);

            await validator.ValidateUpdateAsync(default(string), new ApiLifecycleRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A");
        }
コード例 #2
0
        public async void Name_Update_length()
        {
            Mock <ILifecycleRepository> lifecycleRepository = new Mock <ILifecycleRepository>();

            lifecycleRepository.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(new Lifecycle()));

            var validator = new ApiLifecycleRequestModelValidator(lifecycleRepository.Object);
            await validator.ValidateUpdateAsync(default(string), new ApiLifecycleRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 201));
        }