예제 #1
0
        public async void Name_Update_length()
        {
            Mock <IPipelineStepRepository> pipelineStepRepository = new Mock <IPipelineStepRepository>();

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

            var validator = new ApiPipelineStepRequestModelValidator(pipelineStepRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiPipelineStepRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
        public async void Name_Create_null()
        {
            Mock <IPipelineStepRepository> pipelineStepRepository = new Mock <IPipelineStepRepository>();

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

            var validator = new ApiPipelineStepRequestModelValidator(pipelineStepRepository.Object);
            await validator.ValidateCreateAsync(new ApiPipelineStepRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }
예제 #3
0
        public async void PipelineStepStatusId_Update_Invalid_Reference()
        {
            Mock <IPipelineStepRepository> pipelineStepRepository = new Mock <IPipelineStepRepository>();

            pipelineStepRepository.Setup(x => x.GetPipelineStepStatus(It.IsAny <int>())).Returns(Task.FromResult <PipelineStepStatus>(null));

            var validator = new ApiPipelineStepRequestModelValidator(pipelineStepRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiPipelineStepRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.PipelineStepStatusId, 1);
        }
예제 #4
0
        public async void ShipperId_Create_Invalid_Reference()
        {
            Mock <IPipelineStepRepository> pipelineStepRepository = new Mock <IPipelineStepRepository>();

            pipelineStepRepository.Setup(x => x.GetEmployee(It.IsAny <int>())).Returns(Task.FromResult <Employee>(null));

            var validator = new ApiPipelineStepRequestModelValidator(pipelineStepRepository.Object);

            await validator.ValidateCreateAsync(new ApiPipelineStepRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.ShipperId, 1);
        }