Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Guldborg committed Nov 30, 2023
1 parent 79ab0eb commit 6023ff3
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions coffeecard/CoffeeCard.Tests.Unit/Services/v2/ProductServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Threading.Tasks;
using CoffeeCard.Common.Configuration;
using CoffeeCard.Library.Persistence;
Expand Down Expand Up @@ -71,16 +72,14 @@ await productService.UpdateProduct(new UpdateProductRequest()
AllowedUserGroups = new List<UserGroup>() { UserGroup.Customer, UserGroup.Board }
});

var expected = new List<UserGroup>
{
UserGroup.Customer, UserGroup.Board
};

var result = await productService.GetProductAsync(1);

Assert.Collection<UserGroup>(expected,
e => e.Equals(UserGroup.Customer),
e => e.Equals(UserGroup.Board));
Assert.Collection<ProductUserGroup>(result.ProductUserGroup,
e => Assert.Equal(UserGroup.Customer, e.UserGroup),
e => Assert.Equal(UserGroup.Board, e.UserGroup));

Assert.DoesNotContain(UserGroup.Barista, result.ProductUserGroup.Select(e => e.UserGroup));
Assert.DoesNotContain(UserGroup.Manager, result.ProductUserGroup.Select(e => e.UserGroup));
}

[Fact(DisplayName = "AddProduct adds only selected user groups")]
Expand Down Expand Up @@ -114,16 +113,11 @@ public async Task AddProduct_Sets_Correct_UserGroups()

await productService.AddProduct(p);

var expected = new List<UserGroup>
{
UserGroup.Manager, UserGroup.Board
};

var result = await productService.GetProductAsync(1);

Assert.Collection<UserGroup>(expected,
e => e.Equals(UserGroup.Customer),
e => e.Equals(UserGroup.Board));
Assert.Collection<ProductUserGroup>(result.ProductUserGroup,
e => Assert.Equal(UserGroup.Manager, e.UserGroup),
e => Assert.Equal(UserGroup.Board, e.UserGroup));
}

[Fact(DisplayName = "GetAllProducts shows non-visible products")]
Expand Down

0 comments on commit 6023ff3

Please sign in to comment.