public async Task Handle_Should_ReturnOrderViewModel() { var orderRepoMock = new Mock <IOrderRepository>(); var id = 10; orderRepoMock.Setup(x => x.ListAsync(It.IsAny <ISpecification <Order> >())) .ReturnsAsync( new List <Order>() { new Order("1", new Address("s", "b", "e", "f", "g"), new List <OrderItem>()) { Id = 10 }, new Order("2", new Address("s", "b", "e", "f", "g"), new List <OrderItem>()) { Id = 12 }, new Order("3", new Address("s", "b", "e", "f", "g"), new List <OrderItem>()) { Id = 13 }, }); var getOrderDetailsHandler = new GetOrderDetailsHandler(orderRepoMock.Object); var result = await getOrderDetailsHandler.Handle(new GetOrderDetails("pawel", id), CancellationToken.None); result.Should() .NotBeNull(); result.OrderNumber.Should() .Be(id); }
public async Task BeNullIfORderNotFound() { var request = new GetOrderDetails("SomeName", 100); var handler = new GetOrderDetailsHandler(_mockOrderRepository.Object); var result = await handler.Handle(request, CancellationToken.None); Assert.Null(result); }
public async Task NotBeNullIfOrderExists() { var request = new GetOrderDetails("Some Name:", 0); var handler = new GetOrderDetailsHandler(_mockOrderRepository.Object); var result = await handler.Handle(request, CancellationToken.None); Assert.NotNull(result); }
public async Task BeNull_If_Order_Not_found() { var request = new GetOrderDetails("SomeUserName", 100, OrderStatus.Pending); var handler = new GetOrderDetailsHandler(_mockOrderRepository.Object); var result = await handler.Handle(request, CancellationToken.None); Assert.Null(result); }