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:
Steve Smith
2021-10-25 15:13:02 -04:00
committed by GitHub
parent fee2bbce3d
commit 8a45a2c858
39 changed files with 281 additions and 289 deletions

View File

@@ -1,5 +1,4 @@
using Ardalis.Specification.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Specifications;
using Moq;
using System.Collections.Generic;
@@ -13,16 +12,12 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Specifications
private readonly int _testBasketId = 123;
private readonly string _buyerId = "Test buyerId";
// tests with specifications can use an evaluator or just WhereExpressions.FirstOrDefault if only one
private readonly SpecificationEvaluator<Basket> _evaluator = new SpecificationEvaluator<Basket>();
[Fact]
public void MatchesBasketWithGivenBasketId()
{
var spec = new BasketWithItemsSpecification(_testBasketId);
var result = _evaluator.GetQuery(GetTestBasketCollection().AsQueryable(), spec)
.FirstOrDefault();
var result = spec.Evaluate(GetTestBasketCollection()).FirstOrDefault();
Assert.NotNull(result);
Assert.Equal(_testBasketId, result.Id);
@@ -34,8 +29,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Specifications
int badBasketId = -1;
var spec = new BasketWithItemsSpecification(badBasketId);
var result = _evaluator.GetQuery(GetTestBasketCollection().AsQueryable(), spec)
.Any();
var result = spec.Evaluate(GetTestBasketCollection()).Any();
Assert.False(result);
}
@@ -45,8 +39,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Specifications
{
var spec = new BasketWithItemsSpecification(_buyerId);
var result = _evaluator.GetQuery(GetTestBasketCollection().AsQueryable(), spec)
.FirstOrDefault();
var result = spec.Evaluate(GetTestBasketCollection()).FirstOrDefault();
Assert.NotNull(result);
Assert.Equal(_buyerId, result.BuyerId);
@@ -58,8 +51,7 @@ namespace Microsoft.eShopWeb.UnitTests.ApplicationCore.Specifications
string badBuyerId = "badBuyerId";
var spec = new BasketWithItemsSpecification(badBuyerId);
var result = _evaluator.GetQuery(GetTestBasketCollection().AsQueryable(), spec)
.Any();
var result = spec.Evaluate(GetTestBasketCollection()).Any();
Assert.False(result);
}