Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update packages & migrate to Shouldly #224

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.4.0.108396">
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.5.0.109200">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
18 changes: 9 additions & 9 deletions src/LinkDotNet.StringBuilder/LinkDotNet.StringBuilder.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
Expand Down Expand Up @@ -33,16 +33,16 @@
</None>
</ItemGroup>

<PropertyGroup Label="Analyzer settings">
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>8</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>
<PropertyGroup Label="Analyzer settings">
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>8</AnalysisLevel>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.184">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.186">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -9,11 +9,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\LinkDotNet.StringBuilder\LinkDotNet.StringBuilder.csproj" />
<ProjectReference Include="..\..\src\LinkDotNet.StringBuilder\LinkDotNet.StringBuilder.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
Expand All @@ -8,25 +8,25 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit.v3" Version="1.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit.v3" Version="1.0.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.3">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\LinkDotNet.StringBuilder\LinkDotNet.StringBuilder.csproj" />
<ProjectReference Include="..\..\src\LinkDotNet.StringBuilder\LinkDotNet.StringBuilder.csproj" />
</ItemGroup>

<ItemGroup Label="Global usings">
<Using Include="FluentAssertions" />
<Using Include="Shouldly" />
<Using Include="Xunit" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void ShouldAddString()

stringBuilder.Append("That is a string");

stringBuilder.ToString().Should().Be("That is a string");
stringBuilder.ToString().ShouldBe("That is a string");
}

[Fact]
Expand All @@ -24,7 +24,7 @@ public void ShouldAddMultipleStrings()
stringBuilder.Append("a");
stringBuilder.Append("test");

stringBuilder.ToString().Should().Be("Thisisatest");
stringBuilder.ToString().ShouldBe("Thisisatest");
}

[Fact]
Expand All @@ -34,7 +34,7 @@ public void ShouldAddLargeStrings()

stringBuilder.Append(new string('c', 99));

stringBuilder.ToString().Should().MatchRegex("[c]{99}");
stringBuilder.ToString().ShouldMatch("[c]{99}");
}

[Fact]
Expand All @@ -44,7 +44,7 @@ public void ShouldAppendLine()

stringBuilder.AppendLine("Hello");

stringBuilder.ToString().Should().Contain("Hello").And.Contain(Environment.NewLine);
stringBuilder.ToString().ShouldContain("Hello" + Environment.NewLine);
}

[Fact]
Expand All @@ -54,9 +54,9 @@ public void ShouldAppendSpan()

var returned = stringBuilder.AppendSpan(2);

stringBuilder.Length.Should().Be(2);
stringBuilder.Length.ShouldBe(2);

stringBuilder.ToString().Should().Be(returned.ToString());
stringBuilder.ToString().ShouldBe(returned.ToString());
}

[Fact]
Expand All @@ -66,7 +66,7 @@ public void ShouldOnlyAddNewline()

stringBuilder.AppendLine();

stringBuilder.ToString().Should().Be(Environment.NewLine);
stringBuilder.ToString().ShouldBe(Environment.NewLine);
}

[Fact]
Expand All @@ -76,7 +76,7 @@ public void ShouldGetIndexIfGiven()

stringBuilder.Append("Hello");

stringBuilder[2].Should().Be('l');
stringBuilder[2].ShouldBe('l');
}

[Fact]
Expand All @@ -86,7 +86,7 @@ public void ShouldAppendSpanFormattable()

builder.Append(2.2f);

builder.ToString().Should().Be("2.2");
builder.ToString().ShouldBe("2.2");
}

[Fact]
Expand All @@ -99,7 +99,7 @@ public void ShouldAppendMultipleChars()
builder.Append('c');
}

builder.ToString().Should().MatchRegex("[c]{64}");
builder.ToString().ShouldMatch("[c]{64}");
}

[Fact]
Expand All @@ -111,7 +111,7 @@ public void ShouldAppendMultipleDoubles()
builder.Append(1d / 3d);
builder.Append(1d / 3d);

builder.ToString().Should().Be("0.33333333333333330.33333333333333330.3333333333333333");
builder.ToString().ShouldBe("0.33333333333333330.33333333333333330.3333333333333333");
}

[Fact]
Expand All @@ -121,7 +121,7 @@ public void ShouldAppendGuid()

builder.Append(Guid.Empty);

builder.ToString().Should().Be("00000000-0000-0000-0000-000000000000");
builder.ToString().ShouldBe("00000000-0000-0000-0000-000000000000");
}

[Fact]
Expand Down Expand Up @@ -151,7 +151,7 @@ public void ShouldAppendBoolean(bool value, string expected)

builder.Append(value);

builder.ToString().Should().Be(expected);
builder.ToString().ShouldBe(expected);
}

[Fact]
Expand All @@ -165,7 +165,7 @@ public unsafe void ShouldAddCharPointer()
builder.Append(pText, 5);
}

builder.ToString().Should().Be("Hello");
builder.ToString().ShouldBe("Hello");
}

[Fact]
Expand All @@ -178,7 +178,7 @@ public void GivenMemorySlice_ShouldAppend()

builder.Append(slice);

builder.ToString().Should().Be("ccccc");
builder.ToString().ShouldBe("ccccc");
}

[Fact]
Expand All @@ -189,7 +189,7 @@ public void GivenAStringWithWhitespace_WhenTrimIsCalled_ThenTheStringShouldBeTri

builder.Trim();

builder.ToString().Should().Be("Hello World");
builder.ToString().ShouldBe("Hello World");
}

[Fact]
Expand All @@ -206,7 +206,7 @@ public void GivenMultipleValues_WhenCallingAppend_NotCrashing()

builder.Append(false);

builder.ToString().Should().NotBeNull();
builder.ToString().ShouldNotBeNull();
}

[Fact]
Expand All @@ -215,7 +215,7 @@ public void GivenStringBuilder_WhenAddingSingleCharacter_ThenShouldBeAdded()
using var builder = new ValueStringBuilder();
builder.Append('c');

builder.ToString().Should().Be("c");
builder.ToString().ShouldBe("c");
}

[Fact]
Expand All @@ -229,6 +229,6 @@ public void GivenStringBuilder_WhenAddingIncreasinglyLargerStrings_ThenShouldBeA
builder.Append(new string('e', 4096));
builder.Append(new string('f', 8192));

builder.ToString().Should().MatchRegex("[a]{256}[b]{512}[c]{1024}[d]{2048}[e]{4096}[f]{8192}");
builder.ToString().ShouldMatch("[a]{256}[b]{512}[c]{1024}[d]{2048}[e]{4096}[f]{8192}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void ShouldAppendFormatWithOneArgument(string format, object arg, string

builder.AppendFormat(format, arg);

builder.ToString().Should().Be(expected);
builder.ToString().ShouldBe(expected);
}

[Theory]
Expand Down Expand Up @@ -50,7 +50,7 @@ public void ShouldAppendFormatWithTwoArguments(string format, object arg1, objec

builder.AppendFormat(format, arg1, arg2);

builder.ToString().Should().Be(expected);
builder.ToString().ShouldBe(expected);
}

[Theory]
Expand All @@ -64,7 +64,7 @@ public void ShouldAppendFormatWithThreeArguments(string format, object arg1, obj

builder.AppendFormat(format, arg1, arg2, arg3);

builder.ToString().Should().Be(expected);
builder.ToString().ShouldBe(expected);
}

[Theory]
Expand All @@ -78,7 +78,7 @@ public void ShouldAppendFormatWithFourArguments(string format, object arg1, obje

builder.AppendFormat(format, arg1, arg2, arg3, arg4);

builder.ToString().Should().Be(expected);
builder.ToString().ShouldBe(expected);
}

[Theory]
Expand All @@ -92,6 +92,6 @@ public void ShouldAppendFormatWithFiveArguments(string format, object arg1, obje

builder.AppendFormat(format, arg1, arg2, arg3, arg4, arg5);

builder.ToString().Should().Be(expected);
builder.ToString().ShouldBe(expected);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ShouldAppendWithStringSeparator(string separator, IEnumerable<string

stringBuilder.AppendJoin(separator, values);

stringBuilder.ToString().Should().Be(expected);
stringBuilder.ToString().ShouldBe(expected);
}

[Theory]
Expand All @@ -40,7 +40,7 @@ public void ShouldAppendWithCharSeparator(char separator, IEnumerable<string?> v

stringBuilder.AppendJoin(separator, values);

stringBuilder.ToString().Should().Be(expected);
stringBuilder.ToString().ShouldBe(expected);
}

[Fact]
Expand All @@ -50,7 +50,7 @@ public void ShouldAddDataWithStringSeparator()

stringBuilder.AppendJoin(",", new object[] { 1, 1.05f });

stringBuilder.ToString().Should().Be("1,1.05");
stringBuilder.ToString().ShouldBe("1,1.05");
}

[Fact]
Expand All @@ -60,6 +60,6 @@ public void ShouldAddDataWithCharSeparator()

stringBuilder.AppendJoin(',', new object[] { 1, 1.05f });

stringBuilder.ToString().Should().Be("1,1.05");
stringBuilder.ToString().ShouldBe("1,1.05");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void ShouldInsertString()

valueStringBuilder.Insert(6, "dear ");

valueStringBuilder.ToString().Should().Be("Hello dear World");
valueStringBuilder.ToString().ShouldBe("Hello dear World");
}

[Fact]
Expand All @@ -22,7 +22,7 @@ public void ShouldInsertWhenEmpty()

valueStringBuilder.Insert(0, "Hello");

valueStringBuilder.ToString().Should().Be("Hello");
valueStringBuilder.ToString().ShouldBe("Hello");
}

[Fact]
Expand All @@ -32,7 +32,7 @@ public void ShouldAppendSpanFormattable()

builder.Insert(0, 2.2f);

builder.ToString().Should().Be("2.2");
builder.ToString().ShouldBe("2.2");
}

[Fact]
Expand Down Expand Up @@ -114,7 +114,7 @@ public void ShouldInsertGuid()

builder.Insert(0, Guid.Empty);

builder.ToString().Should().Be("00000000-0000-0000-0000-000000000000");
builder.ToString().ShouldBe("00000000-0000-0000-0000-000000000000");
}

[Fact]
Expand Down Expand Up @@ -142,6 +142,6 @@ public void ShouldInsertBool()

builder.Insert(0, true);

builder.ToString().Should().Be("True");
builder.ToString().ShouldBe("True");
}
}
Loading
Loading