예제 #1
0
        private async void BeUniqueByName_Create_Not_Exists()
        {
            Mock <IChainStatusRepository> chainStatusRepository = new Mock <IChainStatusRepository>();

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

            await validator.ValidateCreateAsync(new ApiChainStatusServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A");
        }
예제 #2
0
        public async void Name_Create_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.ValidateCreateAsync(new ApiChainStatusServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129));
        }