Example #1
0
        public async void Name_Create_length()
        {
            Mock <IProjectRepository> projectRepository = new Mock <IProjectRepository>();

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

            var validator = new ApiProjectRequestModelValidator(projectRepository.Object);
            await validator.ValidateCreateAsync(new ApiProjectRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 201));
        }
Example #2
0
        private async void BeUniqueByName_Create_Not_Exists()
        {
            Mock <IProjectRepository> projectRepository = new Mock <IProjectRepository>();

            projectRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Project>(null));
            var validator = new ApiProjectRequestModelValidator(projectRepository.Object);

            await validator.ValidateCreateAsync(new ApiProjectRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A");
        }