Exemplo n.º 1
0
        public async void Name_Update_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.ValidateUpdateAsync(default(int), new ApiShipMethodRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51));
        }
Exemplo n.º 2
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");
        }
Exemplo n.º 3
0
        public async void Name_Create_null()
        {
            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, null as string);
        }