-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #862 from dlcs/feature/delivery_channel_order
Ensure ImageDeliveryChannels are ordered
- Loading branch information
Showing
4 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/protagonist/DLCS.Repository.Tests/Assets/AssetQueryXTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using DLCS.Model.Assets; | ||
using DLCS.Model.Policies; | ||
using DLCS.Repository.Assets; | ||
using Microsoft.EntityFrameworkCore; | ||
using Test.Helpers.Data; | ||
using Test.Helpers.Integration; | ||
|
||
namespace DLCS.Repository.Tests.Assets; | ||
|
||
[Trait("Category", "Database")] | ||
[Collection(DatabaseCollection.CollectionName)] | ||
public class AssetQueryXTests | ||
{ | ||
private readonly DlcsContext dbContext; | ||
|
||
public AssetQueryXTests(DlcsDatabaseFixture dbFixture) | ||
{ | ||
dbContext = dbFixture.DbContext; | ||
dbFixture.CleanUp(); | ||
} | ||
|
||
[Fact] | ||
public async Task IncludeDeliveryChannelsWithPolicy_ReturnsDeliveryChannels_ByOrderOfChannel() | ||
{ | ||
var assetId = AssetIdGenerator.GetAssetId(); | ||
await dbContext.ImageDeliveryChannels.AddRangeAsync( | ||
new() | ||
{ | ||
ImageId = assetId, Channel = "gamma", | ||
DeliveryChannelPolicyId = KnownDeliveryChannelPolicies.ImageDefault | ||
}, | ||
new() | ||
{ | ||
ImageId = assetId, Channel = "alpha", | ||
DeliveryChannelPolicyId = KnownDeliveryChannelPolicies.ImageDefault | ||
}, | ||
new() | ||
{ | ||
ImageId = assetId, Channel = "beta", | ||
DeliveryChannelPolicyId = KnownDeliveryChannelPolicies.ImageDefault | ||
}); | ||
await dbContext.Images.AddTestAsset(assetId); | ||
await dbContext.SaveChangesAsync(); | ||
|
||
// Act | ||
var result = await dbContext.Images | ||
.Where(i => i.Id == assetId) | ||
.IncludeDeliveryChannelsWithPolicy() | ||
.ToListAsync(); | ||
|
||
// Assert | ||
result.Single().ImageDeliveryChannels.Should().BeInAscendingOrder(idc => idc.Channel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters