コード例 #1
0
        public async Task GetGuestsAsync_ReturnsEmptyList_IfNoGuests()
        {
            // Arrange
            var mapperConfig = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>());
            var mapper       = mapperConfig.CreateMapper();
            var options      = await SetupTestDatabaseAsync(new List <Guest>());

            var httpContextAccessor = new Mock <IHttpContextAccessor>();
            var guestRepository     = new GuestRepository(new WeddingPlannerDbContext(options, httpContextAccessor.Object));
            var guestService        = new GuestService(mapper, guestRepository);

            // Act
            var result = await guestService.GetGuestsAsync();

            // Assert
            result.Should().NotBeNull();
            result.Should().BeOfType <GuestListResponse>();
            result.Item.Guests.Should().NotBeNull();
            result.Item.Guests.Should().BeEmpty();
        }