Ejemplo n.º 1
0
        public async Task Update_WhenTheInvoiceDoesNotExists_ShouldNotUpdate()
        {
            //Arrange
            var request = new UpdateInvoiceRequest
            {
                InvoiceId  = 2,
                Identifier = "INV-02",
                User       = TestsHelpers.CreateUser("2", Roles.Admin)
            };
            var sut = new UpdateInvoiceValidator(_repository.Object);

            //Act
            var result = await sut.ValidateAsync(request);

            //Assert
            result.IsValid.Should().BeFalse();
            result.Errors.Should().Contain(c => c.ErrorCode == Result.NotPresent.StatusCode);
        }
Ejemplo n.º 2
0
        public void Update_WhenIdentifierIsUsedByADifferentInvoice_ShouldNotUpdate()
        {
            //Arrange
            var sut     = new UpdateInvoiceValidator(_repository.Object);
            var request = new UpdateInvoiceRequest
            {
                InvoiceId  = 1,
                Identifier = "INV-002",
                User       = TestsHelpers.CreateUser("1", Roles.Admin)
            };

            //Act
            var result = sut.Validate(request);

            //Assert
            result.IsValid.Should().BeFalse();
            result.Errors.Should().Contain(c => c.ErrorMessage == "The invoice cannot be updated " +
                                           "because another invoice with the new identifier already exists.");
        }