Exemplo n.º 1
0
        public async Task GetListingWithBookingDetail_ExpectsCorrectListing()
        {
            // Arrange
            var bookingService = _fixture.GetService <IBookingService>();
            var newBookingId   = await bookingService.AddBooking(new BookingRequest
            {
                ListingId    = 3,
                BookingDate  = new DateTime(2000, 1, 1),
                Time         = new TimeSpan(1, 1, 1),
                Participants = new List <TourGuest>
                {
                    new TourGuest {
                        Id = 1, FirstName = "firstName", LastName = "lastName"
                    }
                }
            });

            // Act
            var response = await _fixture.Client.GetAsync("/api/listing/3/booking");

            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            // Assert
            var listing = JsonConvert.DeserializeObject <ListingResponse>(responseString);

            listing.Should().NotBeNull();
            listing.Id.Should().Be(3);
            listing.LocationDetail.Should().NotBeNull();
            listing.LocationDetail.Id.Should().Be(139);
            listing.Cost.Should().Be(50);
            listing.Header.Should().Be("desc");
            listing.Description.Should().Be("expect");
            listing.BookingSlots.Count.Should().Be(1);
            var firstBookingSlot = listing.BookingSlots.FirstOrDefault();

            firstBookingSlot.Should().NotBeNull();
            firstBookingSlot?.ListingId.Should().Be(3);
            firstBookingSlot?.BookingDate.Should().Be(new DateTime(2000, 1, 1).ToString("yyyy/MM/dd"));
            firstBookingSlot?.StartTime.Should().Be(new TimeSpan(1, 1, 1).ToString(@"hh\:mm"));
            firstBookingSlot?.Status.Should().Be(BookingStatus.Pending);

            // Cleanup
            await bookingService.DeleteBooking(newBookingId);
        }