Пример #1
0
        public async void Name_Update_null()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

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

            var validator = new ApiChainServerRequestModelValidator(chainRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiChainServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }
Пример #2
0
        private async void BeUniqueByExternalId_Update_Exists()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

            chainRepository.Setup(x => x.ByExternalId(It.IsAny <Guid>())).Returns(Task.FromResult <Chain>(new Chain()));
            var validator = new ApiChainServerRequestModelValidator(chainRepository.Object);

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

            validator.ShouldHaveValidationErrorFor(x => x.ExternalId, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Пример #3
0
        public async void Name_Create_length()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

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

            var validator = new ApiChainServerRequestModelValidator(chainRepository.Object);
            await validator.ValidateCreateAsync(new ApiChainServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
Пример #4
0
        public async void ChainStatusId_Update_Invalid_Reference()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

            chainRepository.Setup(x => x.ChainStatusByChainStatusId(It.IsAny <int>())).Returns(Task.FromResult <ChainStatus>(null));

            var validator = new ApiChainServerRequestModelValidator(chainRepository.Object);

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

            validator.ShouldHaveValidationErrorFor(x => x.ChainStatusId, 1);
        }
Пример #5
0
        public async void TeamId_Create_Invalid_Reference()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

            chainRepository.Setup(x => x.TeamByTeamId(It.IsAny <int>())).Returns(Task.FromResult <Team>(null));

            var validator = new ApiChainServerRequestModelValidator(chainRepository.Object);

            await validator.ValidateCreateAsync(new ApiChainServerRequestModel());

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