2024-05-07 18:05:11 +02:00
|
|
|
namespace AioNet.LinqTest;
|
|
|
|
|
|
|
|
|
|
using AioNet.Linq;
|
|
|
|
|
|
|
|
|
|
public class ExtendedLinqTest
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void FindOneCombinationFor3Elements_SubsequenceLength3()
|
|
|
|
|
{
|
|
|
|
|
var foundCombinations = new[] { 1, 2, 3 }.Combinations(3);
|
|
|
|
|
Assert.Single(foundCombinations);
|
|
|
|
|
|
|
|
|
|
var onlyCombination = foundCombinations.First();
|
|
|
|
|
Assert.Contains(1, onlyCombination);
|
|
|
|
|
Assert.Contains(2, onlyCombination);
|
|
|
|
|
Assert.Contains(3, onlyCombination);
|
|
|
|
|
}
|
2024-05-07 18:12:05 +02:00
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void FindThreeCombinationsFor3Elements_SubsequenceLength2()
|
|
|
|
|
{
|
|
|
|
|
var foundCombinations = new[] { 1, 2, 3 }.Combinations(2);
|
2024-05-07 22:08:21 +02:00
|
|
|
Assert.Equal(3, foundCombinations.Count());
|
2024-05-07 18:12:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData(1)]
|
|
|
|
|
[InlineData(2)]
|
|
|
|
|
[InlineData(3)]
|
|
|
|
|
[InlineData(4)]
|
|
|
|
|
[InlineData(5)]
|
|
|
|
|
public void EachSubsequenceIsCorrectLength(int subsequenceLength)
|
|
|
|
|
{
|
|
|
|
|
var foundCombinations = new[] { 1, 2, 3, 4, 5, 6 }.Combinations(subsequenceLength);
|
|
|
|
|
|
|
|
|
|
foreach (var foundCombination in foundCombinations)
|
|
|
|
|
{
|
2024-05-07 22:08:21 +02:00
|
|
|
Assert.Equal(subsequenceLength, foundCombination.Count());
|
2024-05-07 18:12:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-05-07 18:05:11 +02:00
|
|
|
}
|