Skip to content

Commit

Permalink
Port to xunit and other package updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-martinsmith committed Aug 20, 2024
1 parent b028306 commit 49b1d5e
Show file tree
Hide file tree
Showing 4 changed files with 440 additions and 367 deletions.
1 change: 1 addition & 0 deletions src/DNX.Extensions/DNX.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>disable</Nullable>
</PropertyGroup>

<PropertyGroup>
Expand Down
22 changes: 12 additions & 10 deletions tests/DNX.Extensions.Tests/DNX.Extensions.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Nullable>disable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Bogus" version="29.0.2" />
<PackageReference Include="NBuilder" version="6.1.0" />
<PackageReference Include="NUnit" version="3.12.0" />
<PackageReference Include="NUnit.Console" Version="3.11.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Bogus" version="35.6.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.console" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Shouldly" Version="4.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
using DNX.Extensions.Enumerations;
using NUnit.Framework;
using DNX.Extensions.Enumerations;
using FluentAssertions;
using Xunit;

namespace DNX.Extensions.Tests.Enumerations
{
[TestFixture]
public class EnumerableExtensionsTests
{
[TestCase("", ExpectedResult = false)]
[TestCase(null, ExpectedResult = false)]
[TestCase("a,b,c,d,e,f,g,h,i,j", ExpectedResult = true)]
public bool Test_HasAny(string commaDelimitedArray)
[Theory]
[InlineData("", false)]
[InlineData(null, false)]
[InlineData("a,b,c,d,e,f,g,h,i,j", true)]
public void Test_HasAny(string commaDelimitedArray, bool expectedResult)
{
var enumerable = commaDelimitedArray == null
? null
: commaDelimitedArray.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
var enumerable = commaDelimitedArray?
.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

// Act
var result = enumerable.HasAny();

return result;
// Assert
result.Should().Be(expectedResult);
}

[TestCase("", "1", ExpectedResult = false)]
[TestCase(null, "1", ExpectedResult = false)]
[TestCase("a1,b2,c1,d2,e1,f2,g1,h2,i1,j2", "1", ExpectedResult = true)]
[TestCase("a1,b2,c1,d2,e1,f2,g1,h2,i1,j2", "2", ExpectedResult = true)]
[TestCase("a1,b2,c1,d2,e1,f2,g1,h2,i1,j2", "0", ExpectedResult = false)]
public bool Test_HasAny_predicate(string commaDelimitedArray, string suffix)
[Theory]
[InlineData("", "1", false)]
[InlineData(null, "1", false)]
[InlineData("a1,b2,c1,d2,e1,f2,g1,h2,i1,j2", "1", true)]
[InlineData("a1,b2,c1,d2,e1,f2,g1,h2,i1,j2", "2", true)]
[InlineData("a1,b2,c1,d2,e1,f2,g1,h2,i1,j2", "0", false)]
public void Test_HasAny_predicate(string commaDelimitedArray, string suffix, bool expectedResult)
{
var enumerable = commaDelimitedArray == null
? null
: commaDelimitedArray.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
var enumerable = commaDelimitedArray?
.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

// Act
var result = enumerable.HasAny(s => s.EndsWith(suffix));

return result;
// Assert
result.Should().Be(expectedResult);
}
}
}
Loading

0 comments on commit 49b1d5e

Please sign in to comment.