Update Specification and other packages to latest version (#582)
* Updating repositories and specification version Need to fix broken tests * removing test that would just be testing mocked result now * Refactored from IAsyncRepository and removed it. Tests pass. * Update packages
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.BasketRepositoryTests
|
||||
public class SetQuantities
|
||||
{
|
||||
private readonly CatalogContext _catalogContext;
|
||||
private readonly IAsyncRepository<Basket> _basketRepository;
|
||||
private readonly EfRepository<Basket> _basketRepository;
|
||||
private readonly BasketBuilder BasketBuilder = new BasketBuilder();
|
||||
|
||||
public SetQuantities()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
|
||||
using Microsoft.eShopWeb.Infrastructure.Data;
|
||||
using Microsoft.eShopWeb.UnitTests.Builders;
|
||||
using System.Linq;
|
||||
@@ -11,7 +12,7 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests
|
||||
public class GetById
|
||||
{
|
||||
private readonly CatalogContext _catalogContext;
|
||||
private readonly OrderRepository _orderRepository;
|
||||
private readonly EfRepository<Order> _orderRepository;
|
||||
private OrderBuilder OrderBuilder { get; } = new OrderBuilder();
|
||||
private readonly ITestOutputHelper _output;
|
||||
public GetById(ITestOutputHelper output)
|
||||
@@ -21,7 +22,7 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests
|
||||
.UseInMemoryDatabase(databaseName: "TestCatalog")
|
||||
.Options;
|
||||
_catalogContext = new CatalogContext(dbOptions);
|
||||
_orderRepository = new OrderRepository(_catalogContext);
|
||||
_orderRepository = new EfRepository<Order>(_catalogContext);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -37,6 +38,7 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests
|
||||
Assert.Equal(OrderBuilder.TestBuyerId, orderFromRepo.BuyerId);
|
||||
|
||||
// Note: Using InMemoryDatabase OrderItems is available. Will be null if using SQL DB.
|
||||
// Use the OrderWithItemsByIdSpec instead of just GetById to get the full aggregate
|
||||
var firstItem = orderFromRepo.OrderItems.FirstOrDefault();
|
||||
Assert.Equal(OrderBuilder.TestUnits, firstItem.Units);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
|
||||
using Microsoft.eShopWeb.ApplicationCore.Specifications;
|
||||
using Microsoft.eShopWeb.Infrastructure.Data;
|
||||
using Microsoft.eShopWeb.UnitTests.Builders;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,7 +13,7 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests
|
||||
public class GetByIdWithItemsAsync
|
||||
{
|
||||
private readonly CatalogContext _catalogContext;
|
||||
private readonly OrderRepository _orderRepository;
|
||||
private readonly EfRepository<Order> _orderRepository;
|
||||
private OrderBuilder OrderBuilder { get; } = new OrderBuilder();
|
||||
|
||||
public GetByIdWithItemsAsync()
|
||||
@@ -21,7 +22,7 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests
|
||||
.UseInMemoryDatabase(databaseName: "TestCatalog")
|
||||
.Options;
|
||||
_catalogContext = new CatalogContext(dbOptions);
|
||||
_orderRepository = new OrderRepository(_catalogContext);
|
||||
_orderRepository = new EfRepository<Order>(_catalogContext);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -47,7 +48,8 @@ namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests
|
||||
_catalogContext.SaveChanges();
|
||||
|
||||
//Act
|
||||
var orderFromRepo = await _orderRepository.GetByIdWithItemsAsync(secondOrderId);
|
||||
var spec = new OrderWithItemsByIdSpec(secondOrderId);
|
||||
var orderFromRepo = await _orderRepository.GetBySpecAsync(spec);
|
||||
|
||||
//Assert
|
||||
Assert.Equal(secondOrderId, orderFromRepo.Id);
|
||||
|
||||
Reference in New Issue
Block a user