Exemplo n.º 1
0
        public async void PetId_Update_Valid_Reference()
        {
            Mock <ISaleRepository> saleRepository = new Mock <ISaleRepository>();

            saleRepository.Setup(x => x.PetByPetId(It.IsAny <int>())).Returns(Task.FromResult <Pet>(new Pet()));

            var validator = new ApiSaleServerRequestModelValidator(saleRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSaleServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.PetId, 1);
        }
Exemplo n.º 2
0
        public async void Note_Update_null()
        {
            Mock <ISaleRepository> saleRepository = new Mock <ISaleRepository>();

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

            var validator = new ApiSaleServerRequestModelValidator(saleRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSaleServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Note, null as string);
        }
Exemplo n.º 3
0
        public async void TransactionId_Create_Valid_Reference()
        {
            Mock <ISaleRepository> saleRepository = new Mock <ISaleRepository>();

            saleRepository.Setup(x => x.TransactionByTransactionId(It.IsAny <int>())).Returns(Task.FromResult <Transaction>(new Transaction()));

            var validator = new ApiSaleServerRequestModelValidator(saleRepository.Object);
            await validator.ValidateCreateAsync(new ApiSaleServerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.TransactionId, 1);
        }
Exemplo n.º 4
0
        public async void IpAddress_Create_length()
        {
            Mock <ISaleRepository> saleRepository = new Mock <ISaleRepository>();

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

            var validator = new ApiSaleServerRequestModelValidator(saleRepository.Object);
            await validator.ValidateCreateAsync(new ApiSaleServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.IpAddress, new string('A', 129));
        }
Exemplo n.º 5
0
        public async void PaymentTypeId_Create_Invalid_Reference()
        {
            Mock <ISaleRepository> saleRepository = new Mock <ISaleRepository>();

            saleRepository.Setup(x => x.PaymentTypeByPaymentTypeId(It.IsAny <int>())).Returns(Task.FromResult <PaymentType>(null));

            var validator = new ApiSaleServerRequestModelValidator(saleRepository.Object);

            await validator.ValidateCreateAsync(new ApiSaleServerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.PaymentTypeId, 1);
        }