public async void GetCategoryByIdFalseTest() { using (var context = new ShopContext(_dbContextOptions)) { var goodsQueryHandler = new GoodsQueryHandlers(context); await Assert.ThrowsAnyAsync <DomainException>((async() => await goodsQueryHandler.Handle(new GetGoodsById() { Id = context.Goods.Max(x => x.Id) + 1, }, CancellationToken.None))); } }
public async void GetGoodsTest() { using (var context = new ShopContext(_dbContextOptions)) { var goodsQueryHandler = new GoodsQueryHandlers(context); var result = await goodsQueryHandler.Handle(new GetGoodsQuery(), CancellationToken.None); Assert.NotNull(result); Assert.IsType <QueryResult <GoodsResponse> >(result); } }
public async void GetGoodsByIdTest() { using (var context = new ShopContext(_dbContextOptions)) { var goodsQueryHandler = new GoodsQueryHandlers(context); var result = await goodsQueryHandler.Handle(new GetGoodsById() { Id = context.Goods.First().Id, }, CancellationToken.None); Assert.NotNull(result); Assert.IsType <GoodsResponse>(result); Assert.Equal(result.Id, context.Goods.First().Id); } }