コード例 #1
0
        public async Task GetByIdAsync_ExistingItemListId_Successful()
        {
            // Arrange.
            var itemListEntityToSeed = ItemListEntityToSeed;

            Seed(TripFlipDbContext, itemListEntityToSeed);

            var existingItemListId = itemListEntityToSeed.Id;

            var itemListService = new ItemListService(TripFlipDbContext,
                                                      Mapper,
                                                      CurrentUserService);

            var expectedItemListDto = Mapper.Map <ItemListDto>(itemListEntityToSeed);

            var comparer = new ItemListDtoComparer();

            // Act.
            var resultItemListDto =
                await itemListService.GetByIdAsync(existingItemListId);

            // Assert.
            Assert.AreEqual(0,
                            comparer.Compare(resultItemListDto, expectedItemListDto));
        }
コード例 #2
0
        public async Task GetByIdAsync_NonExistentItemListId_ExceptionThrown()
        {
            // Arrange.
            // There is no ItemList entries in database, so any id will be non-existent.
            var nonExistentItemListId = 1;
            var itemListService       = new ItemListService(TripFlipDbContext, Mapper, CurrentUserService);

            // Act + Assert.
            await Assert.ThrowsExceptionAsync <NotFoundException>(async() =>
                                                                  await itemListService.GetByIdAsync(nonExistentItemListId));
        }