Example #1
0
        public async void Name_Update_length()
        {
            Mock <IChainStatusRepository> chainStatusRepository = new Mock <IChainStatusRepository>();

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

            var validator = new ApiChainStatusServerRequestModelValidator(chainStatusRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiChainStatusServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }
Example #2
0
        private async void BeUniqueByName_Create_Exists()
        {
            Mock <IChainStatusRepository> chainStatusRepository = new Mock <IChainStatusRepository>();

            chainStatusRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <ChainStatus>(new ChainStatus()));
            var validator = new ApiChainStatusServerRequestModelValidator(chainStatusRepository.Object);

            await validator.ValidateCreateAsync(new ApiChainStatusServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, "A");
        }
Example #3
0
        public async void Name_Create_null()
        {
            Mock <IChainStatusRepository> chainStatusRepository = new Mock <IChainStatusRepository>();

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

            var validator = new ApiChainStatusServerRequestModelValidator(chainStatusRepository.Object);
            await validator.ValidateCreateAsync(new ApiChainStatusServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }