Пример #1
0
        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)));
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }