public async Task NotReturnsNUlIfOrdersArePresent() { var request = new GetMyOrders("SomeUsername"); var handler = new GetMyOrdersHandler(_mockOrderRepository.Object); var result = await handler.Handle(request, CancellationToken.None); Assert.NotNull(result); }
public async Task Handle_Should_ThrowNullReferenceException_If_RequstParameterIsNull() { var orderRepositoryMock = new Mock <IOrderRepository>(); var getMyordershandler = new GetMyOrdersHandler(orderRepositoryMock.Object); var act = new Func <Task <IEnumerable <OrderViewModel> > >(() => getMyordershandler.Handle(null, CancellationToken.None)); await act.Should() .ThrowAsync <NullReferenceException>(); }
public async Task NotReturnNull_If_OrdersArePresent() { var request = new GetMyOrders("SomeUserName"); var handler = new GetMyOrdersHandler(new CatalogContext(new DbContextOptions <CatalogContext>())); var result = await handler.Handle(request, CancellationToken.None); Assert.NotNull(result); }
public async Task Handle_Should_ReturnOrdersList_ForProvidedUserName() { var orderRepositoryMock = new Mock <IOrderRepository>(); orderRepositoryMock.Setup(x => x.ListAsync(It.IsAny <ISpecification <Order> >())) .ReturnsAsync( new List <Order>() { new Order("1", new Address("a", "b", "c", "d", "e"), new List <OrderItem>()) }); var getMyordershandler = new GetMyOrdersHandler(orderRepositoryMock.Object); var list = await getMyordershandler.Handle(new GetMyOrders("pawel"), CancellationToken.None); list.Should() .NotBeEmpty(); }