From 058d4e6f5ab53562f232e0d8579501abe49313a6 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 21:42:52 -0500 Subject: [PATCH 1/9] Removing the GetById from IRepository - removed it and updated everywhere, where it was called to use the async version --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Infrastructure/Data/EfRepository.cs | 5 -- src/Web/Services/BasketViewModelService.cs | 46 +++++++++++-------- .../DeleteAsync_Should.cs | 2 +- .../OrderRepositoryTests/GetById.cs | 5 +- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index f7bf51310..595c164b1 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -5,7 +5,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces { public interface IRepository where T : BaseEntity { - T GetById(int id); T GetSingleBySpec(ISpecification spec); IEnumerable ListAll(); IEnumerable List(ISpecification spec); diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index 4fe8c60ac..35b880229 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -21,11 +21,6 @@ public EfRepository(CatalogContext dbContext) _dbContext = dbContext; } - public virtual T GetById(int id) - { - return _dbContext.Set().Find(id); - } - public T GetSingleBySpec(ISpecification spec) { return List(spec).FirstOrDefault(); diff --git a/src/Web/Services/BasketViewModelService.cs b/src/Web/Services/BasketViewModelService.cs index 11e9612fe..b4801f66c 100644 --- a/src/Web/Services/BasketViewModelService.cs +++ b/src/Web/Services/BasketViewModelService.cs @@ -14,10 +14,10 @@ public class BasketViewModelService : IBasketViewModelService { private readonly IAsyncRepository _basketRepository; private readonly IUriComposer _uriComposer; - private readonly IRepository _itemRepository; + private readonly IAsyncRepository _itemRepository; public BasketViewModelService(IAsyncRepository basketRepository, - IRepository itemRepository, + IAsyncRepository itemRepository, IUriComposer uriComposer) { _basketRepository = basketRepository; @@ -34,30 +34,15 @@ public async Task GetOrCreateBasketForUser(string userName) { return await CreateBasketForUser(userName); } - return CreateViewModelFromBasket(basket); + return await CreateViewModelFromBasket(basket); } - private BasketViewModel CreateViewModelFromBasket(Basket basket) + private async Task CreateViewModelFromBasket(Basket basket) { var viewModel = new BasketViewModel(); viewModel.Id = basket.Id; viewModel.BuyerId = basket.BuyerId; - viewModel.Items = basket.Items.Select(i => - { - var itemModel = new BasketItemViewModel() - { - Id = i.Id, - UnitPrice = i.UnitPrice, - Quantity = i.Quantity, - CatalogItemId = i.CatalogItemId - - }; - var item = _itemRepository.GetById(i.CatalogItemId); - itemModel.PictureUrl = _uriComposer.ComposePicUri(item.PictureUri); - itemModel.ProductName = item.Name; - return itemModel; - }) - .ToList(); + viewModel.Items = await GetBasketItems(basket.Items); ; return viewModel; } @@ -73,5 +58,26 @@ private async Task CreateBasketForUser(string userId) Items = new List() }; } + + private async Task> GetBasketItems(IReadOnlyCollection basketItems) + { + var items = new List(); + foreach (var item in basketItems) + { + var itemModel = new BasketItemViewModel + { + Id = item.Id, + UnitPrice = item.UnitPrice, + Quantity = item.Quantity, + CatalogItemId = item.CatalogItemId + }; + var catalogItem = await _itemRepository.GetByIdAsync(item.CatalogItemId); + itemModel.PictureUrl = _uriComposer.ComposePicUri(catalogItem.PictureUri); + itemModel.ProductName = catalogItem.Name; + items.Add(itemModel); + } + + return items; + } } } diff --git a/tests/IntegrationTests/Repositories/BasketItemRepositoryTests/DeleteAsync_Should.cs b/tests/IntegrationTests/Repositories/BasketItemRepositoryTests/DeleteAsync_Should.cs index c9014f1c1..73774c2d7 100644 --- a/tests/IntegrationTests/Repositories/BasketItemRepositoryTests/DeleteAsync_Should.cs +++ b/tests/IntegrationTests/Repositories/BasketItemRepositoryTests/DeleteAsync_Should.cs @@ -38,7 +38,7 @@ public async Task DeleteItemFromBasket() await _basketItemRepository.DeleteAsync(existingBasket.Items.FirstOrDefault()); _catalogContext.SaveChanges(); - var basketFromDB = _basketRepository.GetById(BasketBuilder.BasketId); + var basketFromDB = await _basketRepository.GetByIdAsync(BasketBuilder.BasketId); Assert.Equal(0, basketFromDB.Items.Count); } diff --git a/tests/IntegrationTests/Repositories/OrderRepositoryTests/GetById.cs b/tests/IntegrationTests/Repositories/OrderRepositoryTests/GetById.cs index b069e1ac2..7991c29e2 100644 --- a/tests/IntegrationTests/Repositories/OrderRepositoryTests/GetById.cs +++ b/tests/IntegrationTests/Repositories/OrderRepositoryTests/GetById.cs @@ -4,6 +4,7 @@ using Microsoft.eShopWeb.UnitTests.Builders; using Xunit; using Xunit.Abstractions; +using System.Threading.Tasks; namespace Microsoft.eShopWeb.IntegrationTests.Repositories.OrderRepositoryTests { @@ -24,7 +25,7 @@ public GetById(ITestOutputHelper output) } [Fact] - public void GetsExistingOrder() + public async Task GetsExistingOrder() { var existingOrder = OrderBuilder.WithDefaultValues(); _catalogContext.Orders.Add(existingOrder); @@ -32,7 +33,7 @@ public void GetsExistingOrder() int orderId = existingOrder.Id; _output.WriteLine($"OrderId: {orderId}"); - var orderFromRepo = _orderRepository.GetById(orderId); + var orderFromRepo = await _orderRepository.GetByIdAsync(orderId); Assert.Equal(OrderBuilder.TestBuyerId, orderFromRepo.BuyerId); // Note: Using InMemoryDatabase OrderItems is available. Will be null if using SQL DB. From b8f1ac977de2468767a1e4407e4f0cdb2f70c846 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 21:46:48 -0500 Subject: [PATCH 2/9] Removing ListAll --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Infrastructure/Data/EfRepository.cs | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index 595c164b1..ba65c5512 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -6,7 +6,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces public interface IRepository where T : BaseEntity { T GetSingleBySpec(ISpecification spec); - IEnumerable ListAll(); IEnumerable List(ISpecification spec); T Add(T entity); void Update(T entity); diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index 35b880229..7373656b2 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -30,12 +30,7 @@ public virtual async Task GetByIdAsync(int id) { return await _dbContext.Set().FindAsync(id); } - - public IEnumerable ListAll() - { - return _dbContext.Set().AsEnumerable(); - } - + public async Task> ListAllAsync() { return await _dbContext.Set().ToListAsync(); From b084d4e770c3632193193994536e35ca5d9ab751 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:07:46 -0500 Subject: [PATCH 3/9] Removing List and all the places it was used --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Web/Services/CatalogService.cs | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index ba65c5512..5f7f95c55 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -6,7 +6,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces public interface IRepository where T : BaseEntity { T GetSingleBySpec(ISpecification spec); - IEnumerable List(ISpecification spec); T Add(T entity); void Update(T entity); void Delete(T entity); diff --git a/src/Web/Services/CatalogService.cs b/src/Web/Services/CatalogService.cs index ad7fbebb1..5229aa59a 100644 --- a/src/Web/Services/CatalogService.cs +++ b/src/Web/Services/CatalogService.cs @@ -18,14 +18,14 @@ namespace Microsoft.eShopWeb.Web.Services public class CatalogService : ICatalogService { private readonly ILogger _logger; - private readonly IRepository _itemRepository; + private readonly IAsyncRepository _itemRepository; private readonly IAsyncRepository _brandRepository; private readonly IAsyncRepository _typeRepository; private readonly IUriComposer _uriComposer; public CatalogService( ILoggerFactory loggerFactory, - IRepository itemRepository, + IAsyncRepository itemRepository, IAsyncRepository brandRepository, IAsyncRepository typeRepository, IUriComposer uriComposer) @@ -46,13 +46,13 @@ public async Task GetCatalogItems(int pageIndex, int item new CatalogFilterPaginatedSpecification(itemsPage * pageIndex, itemsPage, brandId, typeId); // the implementation below using ForEach and Count. We need a List. - var itemsOnPage = _itemRepository.List(filterPaginatedSpecification).ToList(); - var totalItems = _itemRepository.Count(filterSpecification); + var itemsOnPage = await _itemRepository.ListAsync(filterPaginatedSpecification); + var totalItems = await _itemRepository.CountAsync(filterSpecification); - itemsOnPage.ForEach(x => + foreach (var itemOnPage in itemsOnPage) { - x.PictureUri = _uriComposer.ComposePicUri(x.PictureUri); - }); + itemOnPage.PictureUri = _uriComposer.ComposePicUri(itemOnPage.PictureUri); + } var vm = new CatalogIndexViewModel() { From dd0a9a598d6c351cfeedfaca79cdc1c366f7b039 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:09:07 -0500 Subject: [PATCH 4/9] Removing Add --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Infrastructure/Data/EfRepository.cs | 8 -------- 2 files changed, 9 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index 5f7f95c55..9f02c993c 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -6,7 +6,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces public interface IRepository where T : BaseEntity { T GetSingleBySpec(ISpecification spec); - T Add(T entity); void Update(T entity); void Delete(T entity); int Count(ISpecification spec); diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index 7373656b2..e81a5d180 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -55,14 +55,6 @@ public async Task CountAsync(ISpecification spec) return await ApplySpecification(spec).CountAsync(); } - public T Add(T entity) - { - _dbContext.Set().Add(entity); - _dbContext.SaveChanges(); - - return entity; - } - public async Task AddAsync(T entity) { _dbContext.Set().Add(entity); From eea7f54ded085f0455ff5fc487b02e037d9f5851 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:10:32 -0500 Subject: [PATCH 5/9] Removing update --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Infrastructure/Data/EfRepository.cs | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index 9f02c993c..0c73fa5da 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -6,7 +6,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces public interface IRepository where T : BaseEntity { T GetSingleBySpec(ISpecification spec); - void Update(T entity); void Delete(T entity); int Count(ISpecification spec); } diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index e81a5d180..be963b5d6 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -62,12 +62,6 @@ public async Task AddAsync(T entity) return entity; } - - public void Update(T entity) - { - _dbContext.Entry(entity).State = EntityState.Modified; - _dbContext.SaveChanges(); - } public async Task UpdateAsync(T entity) { From 427961095ac0861e98219b3452ee6722dd51d64e Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:11:19 -0500 Subject: [PATCH 6/9] Remove Delete --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Infrastructure/Data/EfRepository.cs | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index 0c73fa5da..8d5c38e04 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -6,7 +6,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces public interface IRepository where T : BaseEntity { T GetSingleBySpec(ISpecification spec); - void Delete(T entity); int Count(ISpecification spec); } } diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index be963b5d6..b5afbee9f 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -68,12 +68,6 @@ public async Task UpdateAsync(T entity) _dbContext.Entry(entity).State = EntityState.Modified; await _dbContext.SaveChangesAsync(); } - - public void Delete(T entity) - { - _dbContext.Set().Remove(entity); - _dbContext.SaveChanges(); - } public async Task DeleteAsync(T entity) { From 1ba52becaaf9dacbfa1c9d56853228c6d075395c Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:12:43 -0500 Subject: [PATCH 7/9] Remove count --- src/ApplicationCore/Interfaces/IRepository.cs | 1 - src/Infrastructure/Data/EfRepository.cs | 5 ----- 2 files changed, 6 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index 8d5c38e04..c9414d170 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -6,6 +6,5 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces public interface IRepository where T : BaseEntity { T GetSingleBySpec(ISpecification spec); - int Count(ISpecification spec); } } diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index b5afbee9f..45f1ac5ca 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -45,11 +45,6 @@ public async Task> ListAsync(ISpecification spec) return await ApplySpecification(spec).ToListAsync(); } - public int Count(ISpecification spec) - { - return ApplySpecification(spec).Count(); - } - public async Task CountAsync(ISpecification spec) { return await ApplySpecification(spec).CountAsync(); From 1152f4a45da4b93137e58eba57d103222bbeaad0 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:16:31 -0500 Subject: [PATCH 8/9] Remove GetSingleBySpec --- src/ApplicationCore/Interfaces/IRepository.cs | 2 +- src/Infrastructure/Data/EfRepository.cs | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs index c9414d170..b4e475e6c 100644 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ b/src/ApplicationCore/Interfaces/IRepository.cs @@ -5,6 +5,6 @@ namespace Microsoft.eShopWeb.ApplicationCore.Interfaces { public interface IRepository where T : BaseEntity { - T GetSingleBySpec(ISpecification spec); + } } diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index 45f1ac5ca..6db70966a 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -20,12 +20,7 @@ public EfRepository(CatalogContext dbContext) { _dbContext = dbContext; } - - public T GetSingleBySpec(ISpecification spec) - { - return List(spec).FirstOrDefault(); - } - + public virtual async Task GetByIdAsync(int id) { return await _dbContext.Set().FindAsync(id); @@ -36,10 +31,6 @@ public async Task> ListAllAsync() return await _dbContext.Set().ToListAsync(); } - public IEnumerable List(ISpecification spec) - { - return ApplySpecification(spec).AsEnumerable(); - } public async Task> ListAsync(ISpecification spec) { return await ApplySpecification(spec).ToListAsync(); From 8a00269ebd7991022b851ab82dba5c9661035cf2 Mon Sep 17 00:00:00 2001 From: Eric Fleming Date: Fri, 1 Mar 2019 22:21:12 -0500 Subject: [PATCH 9/9] Removing IRepository - This also involved cleaning up places where IRepository was still being references in Startup - Removed unused repository from Basket service --- src/ApplicationCore/Interfaces/IRepository.cs | 10 ---------- src/ApplicationCore/Services/BasketService.cs | 3 --- src/Infrastructure/Data/EfRepository.cs | 2 +- src/Web/Startup.cs | 3 +-- .../Services/BasketServiceTests/DeleteBasket.cs | 2 +- .../Services/BasketServiceTests/SetQuantities.cs | 4 ++-- .../Services/BasketServiceTests/TransferBasket.cs | 4 ++-- 7 files changed, 7 insertions(+), 21 deletions(-) delete mode 100644 src/ApplicationCore/Interfaces/IRepository.cs diff --git a/src/ApplicationCore/Interfaces/IRepository.cs b/src/ApplicationCore/Interfaces/IRepository.cs deleted file mode 100644 index b4e475e6c..000000000 --- a/src/ApplicationCore/Interfaces/IRepository.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.eShopWeb.ApplicationCore.Entities; -using System.Collections.Generic; - -namespace Microsoft.eShopWeb.ApplicationCore.Interfaces -{ - public interface IRepository where T : BaseEntity - { - - } -} diff --git a/src/ApplicationCore/Services/BasketService.cs b/src/ApplicationCore/Services/BasketService.cs index 7d3011a65..1f39f85a2 100644 --- a/src/ApplicationCore/Services/BasketService.cs +++ b/src/ApplicationCore/Services/BasketService.cs @@ -15,10 +15,8 @@ public class BasketService : IBasketService private readonly IAsyncRepository _basketItemRepository; private readonly IUriComposer _uriComposer; private readonly IAppLogger _logger; - private readonly IRepository _itemRepository; public BasketService(IAsyncRepository basketRepository, - IRepository itemRepository, IUriComposer uriComposer, IAppLogger logger, IAsyncRepository basketItemRepository) @@ -26,7 +24,6 @@ public BasketService(IAsyncRepository basketRepository, _basketRepository = basketRepository; _uriComposer = uriComposer; _logger = logger; - _itemRepository = itemRepository; _basketItemRepository = basketItemRepository; } diff --git a/src/Infrastructure/Data/EfRepository.cs b/src/Infrastructure/Data/EfRepository.cs index 6db70966a..8688e14f1 100644 --- a/src/Infrastructure/Data/EfRepository.cs +++ b/src/Infrastructure/Data/EfRepository.cs @@ -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/ /// /// - public class EfRepository : IRepository, IAsyncRepository where T : BaseEntity + public class EfRepository : IAsyncRepository where T : BaseEntity { protected readonly CatalogContext _dbContext; diff --git a/src/Web/Startup.cs b/src/Web/Startup.cs index 2bf29e328..a8c41a87f 100644 --- a/src/Web/Startup.cs +++ b/src/Web/Startup.cs @@ -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(); diff --git a/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/DeleteBasket.cs b/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/DeleteBasket.cs index dae2c64b2..79bdd1841 100644 --- a/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/DeleteBasket.cs +++ b/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/DeleteBasket.cs @@ -26,7 +26,7 @@ public async Task Should_InvokeBasketRepoOnceAndBasketItemRepoTwice_Given_TwoIte basket.AddItem(2, It.IsAny(), It.IsAny()); _mockBasketRepo.Setup(x => x.GetByIdAsync(It.IsAny())) .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()); diff --git a/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/SetQuantities.cs b/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/SetQuantities.cs index 7de18e384..9c5f11dfa 100644 --- a/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/SetQuantities.cs +++ b/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/SetQuantities.cs @@ -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(async () => await basketService.SetQuantities(_invalidId, new System.Collections.Generic.Dictionary())); @@ -30,7 +30,7 @@ await Assert.ThrowsAsync(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(async () => await basketService.SetQuantities(123, null)); diff --git a/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/TransferBasket.cs b/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/TransferBasket.cs index 41e106990..38c0a3066 100644 --- a/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/TransferBasket.cs +++ b/tests/UnitTests/ApplicationCore/Services/BasketServiceTests/TransferBasket.cs @@ -9,7 +9,7 @@ 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(async () => await basketService.TransferBasketAsync(null, "steve")); } @@ -17,7 +17,7 @@ public async void ThrowsGivenNullAnonymousId() [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(async () => await basketService.TransferBasketAsync("abcdefg", null)); }