Skip to content

Commit

Permalink
Removing IRepository
Browse files Browse the repository at this point in the history
- This also involved cleaning up places where IRepository was still being references in Startup
- Removed unused repository from Basket service
  • Loading branch information
efleming18 committed Mar 2, 2019
1 parent 1152f4a commit 8a00269
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 21 deletions.
10 changes: 0 additions & 10 deletions src/ApplicationCore/Interfaces/IRepository.cs

This file was deleted.

3 changes: 0 additions & 3 deletions src/ApplicationCore/Services/BasketService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ public class BasketService : IBasketService
private readonly IAsyncRepository<BasketItem> _basketItemRepository;
private readonly IUriComposer _uriComposer;
private readonly IAppLogger<BasketService> _logger;
private readonly IRepository<CatalogItem> _itemRepository;

public BasketService(IAsyncRepository<Basket> basketRepository,
IRepository<CatalogItem> itemRepository,
IUriComposer uriComposer,
IAppLogger<BasketService> logger,
IAsyncRepository<BasketItem> basketItemRepository)
{
_basketRepository = basketRepository;
_uriComposer = uriComposer;
_logger = logger;
_itemRepository = itemRepository;
_basketItemRepository = basketItemRepository;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Data/EfRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
/// https://blogs.msdn.microsoft.com/pfxteam/2012/04/13/should-i-expose-synchronous-wrappers-for-asynchronous-methods/
/// </summary>
/// <typeparam name="T"></typeparam>
public class EfRepository<T> : IRepository<T>, IAsyncRepository<T> where T : BaseEntity
public class EfRepository<T> : IAsyncRepository<T> where T : BaseEntity
{
protected readonly CatalogContext _dbContext;

Expand Down
3 changes: 1 addition & 2 deletions src/Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ public void ConfigureServices(IServiceCollection services)
ConfigureCookieSettings(services);

CreateIdentityIfNotCreated(services);

services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));

services.AddScoped(typeof(IAsyncRepository<>), typeof(EfRepository<>));

services.AddScoped<ICatalogService, CachedCatalogService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task Should_InvokeBasketRepoOnceAndBasketItemRepoTwice_Given_TwoIte
basket.AddItem(2, It.IsAny<decimal>(), It.IsAny<int>());
_mockBasketRepo.Setup(x => x.GetByIdAsync(It.IsAny<int>()))
.ReturnsAsync(basket);
var basketService = new BasketService(_mockBasketRepo.Object, null, null, null, _mockBasketItemRepo.Object);
var basketService = new BasketService(_mockBasketRepo.Object, null, null, _mockBasketItemRepo.Object);

await basketService.DeleteBasketAsync(It.IsAny<int>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public SetQuantities()
[Fact]
public async void ThrowsGivenInvalidBasketId()
{
var basketService = new BasketService(_mockBasketRepo.Object, null, null, null, null);
var basketService = new BasketService(_mockBasketRepo.Object, null, null, null);

await Assert.ThrowsAsync<BasketNotFoundException>(async () =>
await basketService.SetQuantities(_invalidId, new System.Collections.Generic.Dictionary<string, int>()));
Expand All @@ -30,7 +30,7 @@ await Assert.ThrowsAsync<BasketNotFoundException>(async () =>
[Fact]
public async void ThrowsGivenNullQuantities()
{
var basketService = new BasketService(null, null, null, null, null);
var basketService = new BasketService(null, null, null, null);

await Assert.ThrowsAsync<ArgumentNullException>(async () =>
await basketService.SetQuantities(123, null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public class TransferBasket
[Fact]
public async void ThrowsGivenNullAnonymousId()
{
var basketService = new BasketService(null, null, null, null, null);
var basketService = new BasketService(null, null, null, null);

await Assert.ThrowsAsync<ArgumentNullException>(async () => await basketService.TransferBasketAsync(null, "steve"));
}

[Fact]
public async void ThrowsGivenNullUserId()
{
var basketService = new BasketService(null, null, null, null, null);
var basketService = new BasketService(null, null, null, null);

await Assert.ThrowsAsync<ArgumentNullException>(async () => await basketService.TransferBasketAsync("abcdefg", null));
}
Expand Down

0 comments on commit 8a00269

Please sign in to comment.