Esempio n. 1
0
        public async Task Cancel_WhenCancelARental_ShouldReturnsTheRentalCanceled()
        {
            var rentalId = 1;

            _serviceMock.Setup(s => s.CancelRental(It.IsAny <long>()))
            .ReturnsAsync(new RentalDto
            {
                Id        = rentalId,
                ClientId  = 1,
                VehicleId = 1,
                StartDate = new DateTime(2021, 04, 01),
                EndDate   = new DateTime(2021, 04, 10),
                Canceled  = true
            });

            var result = await _sut.Cancel(rentalId);

            result.Should().BeOfType(typeof(OkObjectResult));
            var rentalCanceled = result.As <ObjectResult>().Value.As <RentalResponseModel>();

            rentalCanceled.Id.Should().Be(rentalId);
            rentalCanceled.Canceled.Should().BeTrue();

            _serviceMock.Verify(s => s.CancelRental(It.Is <long>(v => v == rentalId)), Times.Once);
        }