コード例 #1
0
        public async void Name_Create_length()
        {
            Mock <ITeamRepository> teamRepository = new Mock <ITeamRepository>();

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

            var validator = new ApiTeamServerRequestModelValidator(teamRepository.Object);
            await validator.ValidateCreateAsync(new ApiTeamServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
コード例 #2
0
        public async void OrganizationId_Create_Valid_Reference()
        {
            Mock <ITeamRepository> teamRepository = new Mock <ITeamRepository>();

            teamRepository.Setup(x => x.OrganizationByOrganizationId(It.IsAny <int>())).Returns(Task.FromResult <Organization>(new Organization()));

            var validator = new ApiTeamServerRequestModelValidator(teamRepository.Object);
            await validator.ValidateCreateAsync(new ApiTeamServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.OrganizationId, 1);
        }
コード例 #3
0
        private async void BeUniqueByName_Create_Not_Exists()
        {
            Mock <ITeamRepository> teamRepository = new Mock <ITeamRepository>();

            teamRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Team>(null));
            var validator = new ApiTeamServerRequestModelValidator(teamRepository.Object);

            await validator.ValidateCreateAsync(new ApiTeamServerRequestModel());

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