Move the SetWeight logic to WeightedCollectionBuilderBase so other collections can use it too

This commit is contained in:
Patrick de Mooij
2021-02-08 12:58:10 +01:00
committed by Nathan Woulfe
parent 17e43a6b09
commit 499d22aa20
3 changed files with 30 additions and 22 deletions

View File

@@ -442,6 +442,19 @@ namespace Umbraco.Tests.Composing
AssertCollection(col, typeof(Resolved2), typeof(Resolved1));
}
[Test]
public void WeightedBuilderSetWeight()
{
var builder = _composition.WithCollectionBuilder<TestCollectionBuilderWeighted>()
.Add<Resolved1>()
.Add<Resolved2>();
builder.SetWeight<Resolved1>(10);
var factory = _composition.CreateFactory();
var col = builder.CreateCollection(factory);
AssertCollection(col, typeof(Resolved1), typeof(Resolved2));
}
#region Assertions
private static void AssertCollection(IEnumerable<Resolved> col, params Type[] expected)