added test project for AdventOfCode.Extensions
This commit is contained in:
parent
dc0d579697
commit
4a5eeb8cf0
|
|
@ -0,0 +1,25 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
|
||||
<PackageReference Include="xunit" Version="2.9.2"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdventOfCode.Extensions\AdventOfCode.Extensions.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
using AdventOfCode.Extensions;
|
||||
namespace AdventOfCode.Extensions.Tests;
|
||||
|
||||
public class EnumerableExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void Combinations_12_2_equals_12_21()
|
||||
{
|
||||
int[] data = [1, 2];
|
||||
|
||||
var actual = data.Combinations(2).ToArray();
|
||||
|
||||
Assert.Contains([1, 2], actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Combinations_123_2_equals_12_13_23()
|
||||
{
|
||||
int[] data = [1, 2, 3];
|
||||
|
||||
var actual = data.Combinations(2).ToArray();
|
||||
|
||||
Assert.Contains([1, 2], actual);
|
||||
Assert.Contains([1, 3], actual);
|
||||
Assert.Contains([2, 3], actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Combinations_123_3_equals_123()
|
||||
{
|
||||
int[] data = [1, 2, 3];
|
||||
|
||||
var actual = data.Combinations(3).ToArray();
|
||||
|
||||
Assert.Contains([1, 2, 3], actual);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ public static class EnumerableExtensions
|
|||
{
|
||||
var validIndex = false;
|
||||
var currentIndex = 0;
|
||||
foreach (var i in Range(0, count).Reverse())
|
||||
for(var i = count - 1; i >= 0; i--)
|
||||
{
|
||||
currentIndex = i;
|
||||
if (indices[i] != i + poolLength - count)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode.HelperClasses.
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode.Downloader", "AdventOfCode.Downloader\AdventOfCode.Downloader.csproj", "{43B006C3-5296-452B-BD86-225574C0E2A2}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HelperClasses", "HelperClasses", "{60EAF50E-3D09-4886-A237-984AF6F40119}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Contracts", "Contracts", "{19D1A1FA-0E80-4C2C-A542-5AB6FB3FB18D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdventOfCode.Extensions.Tests", "AdventOfCode.Extensions.Tests\AdventOfCode.Extensions.Tests.csproj", "{FCED95A0-13EC-4DB0-B572-592398BB30F3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -56,10 +64,19 @@ Global
|
|||
{43B006C3-5296-452B-BD86-225574C0E2A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{43B006C3-5296-452B-BD86-225574C0E2A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{43B006C3-5296-452B-BD86-225574C0E2A2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FCED95A0-13EC-4DB0-B572-592398BB30F3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{4F395AE3-DABB-4546-A4D0-5A62425FE168} = {05EBAA1C-B33B-4AFE-8635-A58D7CA509A7}
|
||||
{197D9628-C2D1-4B33-9DB8-134F87F79904} = {05EBAA1C-B33B-4AFE-8635-A58D7CA509A7}
|
||||
{FAB5E28F-706A-4DE1-B5FD-54E31C3A8405} = {05EBAA1C-B33B-4AFE-8635-A58D7CA509A7}
|
||||
{D47175BB-5AD6-43A8-9287-FF5E6F1816E3} = {60EAF50E-3D09-4886-A237-984AF6F40119}
|
||||
{3D09528A-09A7-4B0B-9D45-7D3AAB26449A} = {60EAF50E-3D09-4886-A237-984AF6F40119}
|
||||
{0249A329-D5C1-4699-88BE-A668B362432E} = {19D1A1FA-0E80-4C2C-A542-5AB6FB3FB18D}
|
||||
{1466A0F6-7C88-47FF-B8F8-FF30368E26DC} = {F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61}
|
||||
{FCED95A0-13EC-4DB0-B572-592398BB30F3} = {F6AF8AA9-D28F-4DC0-A689-0A1451DC6B61}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
Loading…
Reference in New Issue