Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public async void ChainStatusId_Update_Valid_Reference()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

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

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

            validator.ShouldNotHaveValidationErrorFor(x => x.ChainStatusId, 1);
        }
Ejemplo n.º 3
0
        public async void TeamId_Create_Valid_Reference()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

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

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

            validator.ShouldNotHaveValidationErrorFor(x => x.TeamId, 1);
        }
Ejemplo n.º 4
0
        private async void BeUniqueByExternalId_Update_Not_Exists()
        {
            Mock <IChainRepository> chainRepository = new Mock <IChainRepository>();

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

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

            validator.ShouldNotHaveValidationErrorFor(x => x.ExternalId, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
        }
Ejemplo n.º 5
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));
        }