public async Task GetAllAsync() { //Arrange var mockProducts = new Mock <IProductService>(); mockProducts.Setup(repo => repo.GetByIdAsync(Guid.Parse(ProductId))) .Returns(Task.FromResult(new ProductDto { Name = "Test product", CurrentPrice = 100 })); var mockCustomer = new Mock <ICustomerService>(); mockCustomer.Setup(repo => repo.GetByIdAsync(Guid.Parse(CustomerId))) .Returns(Task.FromResult(new CustomerDto { Name = "Test customer" })); var mockRepo = new Mock <IRepository <Order, Guid> >(); mockRepo.Setup(repo => repo.GetAll()).Returns(GetOrders()); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(uow => uow.Orders).Returns(mockRepo.Object); var provider = new OrderProvider(mockUnitOfWork.Object, mockCustomer.Object, mockProducts.Object, CreateMapper()); //Act var result = await provider.GetAllAsync(1, 1); Assert.NotNull(result); var firstOrder = result.Values.FirstOrDefault(); Assert.Equal("Test orders", firstOrder.Number); Assert.NotNull(firstOrder.Customer); Assert.IsType <CustomerDto>(firstOrder.Customer); Assert.Equal("Test customer", firstOrder.Customer.Name); Assert.NotNull(firstOrder.Products); Assert.IsType <ProductDto>(firstOrder.Products.First()); Assert.Equal("Test product", firstOrder.Products.First().Name); }