Skip to content

Update to AwesomeAssertions #47611

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

Merged
merged 10 commits into from
Apr 3, 2025
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageVersion Include="FluentAssertions.Json" Version="$(FluentAssertionsJsonVersion)" />
<PackageVersion Include="AwesomeAssertions" Version="$(AwesomeAssertionsVersion)" />
<PackageVersion Include="AwesomeAssertions.Json" Version="$(AwesomeAssertionsJsonVersion)" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="$(MicrosoftApplicationInsightsPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" Version="$(MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion)" />
Expand Down
13 changes: 2 additions & 11 deletions eng/Signing.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,14 @@
</ItemGroup>

<!--
These are third party libraries that we use in Arcade. We need to sign them even if they
are already signed. However, they must be signed with a 3rd party certificate.
Arcade is no longer signed so we don't have to sign test assemblies.
ReSign 3rd party files that we use in the product
-->
<ItemGroup>
<FileSignInfo Include="MessagePack.Annotations.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="MessagePack.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Nerdbank.Streams.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Newtonsoft.Json.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="CommandLine.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="FluentAssertions.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="FluentAssertions.Core.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="FluentAssertions.Json.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Microsoft.3rdpartytools.MarkdownLog.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="xunit.performance.api.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="xunit.performance.core.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="xunit.performance.execution.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="xunit.performance.metrics.dll" CertificateName="$(ExternalCertificateId)" />
<FileSignInfo Include="Valleysoft.DockerCredsProvider.dll" CertificateName="$(ExternalCertificateId)" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@
</PropertyGroup>
<!-- Test Dependencies -->
<PropertyGroup>
<FluentAssertionsVersion>6.12.0</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>6.1.0</FluentAssertionsJsonVersion>
<AwesomeAssertionsVersion>8.0.2</AwesomeAssertionsVersion>
<AwesomeAssertionsJsonVersion>8.0.0</AwesomeAssertionsJsonVersion>
<MoqPackageVersion>4.18.4</MoqPackageVersion>
<MSTestVersion>3.9.0-preview.25181.5</MSTestVersion>
<XunitCombinatorialVersion>1.3.2</XunitCombinatorialVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions.Json" />
<PackageReference Include="AwesomeAssertions.Json" />
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions.Json" />
<PackageReference Include="AwesomeAssertions.Json" />
<PackageReference Include="Microsoft.Build" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" />
Expand Down
2 changes: 1 addition & 1 deletion test/ArgumentsReflector/ArgumentsReflector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Global usings removal -->
<!-- See: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#using -->
<ItemGroup>
<Using Remove="FluentAssertions" />
<Using Remove="AwesomeAssertions" />
<Using Remove="Microsoft.NET.TestFramework" />
<Using Remove="Microsoft.NET.TestFramework.Assertions" />
<Using Remove="Microsoft.NET.TestFramework.Commands" />
Expand Down
4 changes: 4 additions & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<IncludeSymbols>false</IncludeSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AwesomeAssertions" />
</ItemGroup>

<!-- Global usings -->
<!-- See: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#using -->
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/HelixTasks/HelixTasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<!-- Global usings removal -->
<!-- See: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#using -->
<ItemGroup>
<Using Remove="FluentAssertions" />
<Using Remove="AwesomeAssertions" />
<Using Remove="Microsoft.NET.TestFramework" />
<Using Remove="Microsoft.NET.TestFramework.Assertions" />
<Using Remove="Microsoft.NET.TestFramework.Commands" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

<ItemGroup>
<PackageReference Include="FakeItEasy" />
<PackageReference Include="FluentAssertions" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void The_RuntimeFrameworkVersion_can_float()
// we know about, so that when a new runtime patch is released the test doesn't
// immediately start failing
var minimumExpectedVersion = new NuGetVersion(TestContext.LatestRuntimePatchForNetCoreApp2_0);
netCoreAppLibrary.Version.CompareTo(minimumExpectedVersion).Should().BeGreaterOrEqualTo(0,
netCoreAppLibrary.Version.CompareTo(minimumExpectedVersion).Should().BeGreaterThanOrEqualTo(0,
"the version resolved from a RuntimeFrameworkVersion of '{0}' should be at least {1}",
testProject.RuntimeFrameworkVersion, TestContext.LatestRuntimePatchForNetCoreApp2_0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ public static void Test()

var newtonsoftReferences = packageReferences.Where(pr => pr.value == "Newtonsoft.Json");

newtonsoftReferences.Count().Should().BeGreaterOrEqualTo(1);
newtonsoftReferences.Count().Should().BeGreaterThanOrEqualTo(1);

foreach (var r in newtonsoftReferences)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Build" />
<PackageReference Include="NuGet.ProjectModel" />
<PackageReference Include="NuGet.LibraryModel" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
<PackageId>testSdkClean</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions test/Microsoft.NET.Pack.Tests/Microsoft.NET.Pack.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<PackageId>testSdkPack</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions.Json" />
<PackageReference Include="AwesomeAssertions.Json" />
<PackageReference Include="System.Reflection.MetadataLoadContext" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<PackageId>testSdkRebuild</PackageId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="NuGet.Packaging" />
<PackageReference Include="NuGet.ProjectModel" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Moq" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Moq" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.Build.Framework" />
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Moq" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions.Json" />
<PackageReference Include="System.Reflection.MetadataLoadContext" />
</ItemGroup>

Expand Down
14 changes: 4 additions & 10 deletions test/Microsoft.NET.TestFramework/Assertions/AssemblyAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using FluentAssertions.Execution;
using FluentAssertions;

namespace Microsoft.NET.TestFramework.Assertions
{
Expand All @@ -22,29 +22,23 @@ public AndConstraint<AssemblyAssertions> ContainType(string expectedType)
{
var types = GetDeclaredTypeNames();

Execute.Assertion
.ForCondition(types.Contains(expectedType))
.FailWith($"Expected type {expectedType} to be in assembly, but it is not.");
types.Should().Contain(expectedType, $"Expected type {expectedType} to be in assembly, but it is not.");
return new AndConstraint<AssemblyAssertions>(this);
}

public AndConstraint<AssemblyAssertions> NotContainType(string expectedType)
{
var types = GetDeclaredTypeNames();

Execute.Assertion
.ForCondition(!types.Contains(expectedType))
.FailWith($"Expected type {expectedType} to not be in assembly, but it is.");
types.Should().NotContain(expectedType, $"Expected type {expectedType} to not be in assembly, but it is.");
return new AndConstraint<AssemblyAssertions>(this);
}

public AndConstraint<AssemblyAssertions> HaveAttribute(string expectedAttribute)
{
var attributes = GetAssemblyAttributes();

Execute.Assertion
.ForCondition(attributes.Contains(expectedAttribute))
.FailWith($"Expected attribute {expectedAttribute} to be in assembly, but it is not.");
attributes.Should().Contain(expectedAttribute, $"Expected attribute {expectedAttribute} to be in assembly, but it is not.");
return new AndConstraint<AssemblyAssertions>(this);
}

Expand Down
Loading