示例#1
0
        private async void BeUniqueByName_Create_Not_Exists()
        {
            Mock <IShipMethodRepository> shipMethodRepository = new Mock <IShipMethodRepository>();

            shipMethodRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <ShipMethod>(null));
            var validator = new ApiShipMethodRequestModelValidator(shipMethodRepository.Object);

            await validator.ValidateCreateAsync(new ApiShipMethodRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.Name, "A");
        }
示例#2
0
        public async void Name_Create_length()
        {
            Mock <IShipMethodRepository> shipMethodRepository = new Mock <IShipMethodRepository>();

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

            var validator = new ApiShipMethodRequestModelValidator(shipMethodRepository.Object);
            await validator.ValidateCreateAsync(new ApiShipMethodRequestModel());

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