예제 #1
0
        public async Task CancelRental_WhenCancelARental_ShouldUpdateCanceledProp()
        {
            _dbContext.Rentals.Add(new Rental
            {
                ClientId  = 2,
                VehicleId = 5,
                StartDate = new DateTime(2021, 4, 1),
                EndDate   = new DateTime(2021, 4, 10),
            });
            _dbContext.SaveChanges();

            await _sut.CancelRental(1);

            var rentalAdded = await _dbContext.Rentals.FirstOrDefaultAsync();

            rentalAdded.Id.Should().Be(1);
            rentalAdded.ClientId.Should().Be(2);
            rentalAdded.VehicleId.Should().Be(5);
            rentalAdded.StartDate.Should().Be(new DateTime(2021, 4, 1));
            rentalAdded.EndDate.Should().Be(new DateTime(2021, 4, 10));
            rentalAdded.Canceled.Should().BeTrue();
        }