Skip to content

Commit

Permalink
added Issue 4670
Browse files Browse the repository at this point in the history
  • Loading branch information
OsirisTerje committed Mar 23, 2024
1 parent fe6c335 commit bf0381c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions Issue4670/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using NUnit.Framework;
26 changes: 26 additions & 0 deletions Issue4670/Issue4670.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
22 changes: 22 additions & 0 deletions Issue4670/Issue4670.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Issue4670", "Issue4670.csproj", "{491A5BD4-1DCE-48C1-92AA-D39307FCD7A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{491A5BD4-1DCE-48C1-92AA-D39307FCD7A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{491A5BD4-1DCE-48C1-92AA-D39307FCD7A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{491A5BD4-1DCE-48C1-92AA-D39307FCD7A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{491A5BD4-1DCE-48C1-92AA-D39307FCD7A0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
28 changes: 28 additions & 0 deletions Issue4670/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Issue4670;

public class Tests
{
[Test]
public void BugReport()
{
var dictionary = new Dictionary<string, int>
{
{ "a", 123 },
{ "b", 456 }
};

Assert.Multiple(() =>
{
Assert.That(dictionary, Does.ContainKey("a").WithValue(456).Or.ContainKey("b").WithValue(123), "Passes but should fail");
Assert.That(dictionary, Does.ContainKey("a").WithValue(456).And.ContainKey("b").WithValue(456), "Passes but should fail");

// Expected: dictionary containing key "c" or dictionary containing entry ["c", 456]
// But was: < ["a", 123], ["b", 456] >
Assert.That(dictionary, Does.ContainKey("a").WithValue(123).Or.ContainKey("c").WithValue(456), "Fails but should pass");

// Expected: dictionary containing key "c" and dictionary containing entry ["c", 456]
// But was: < ["a", 123], ["b", 456] >
Assert.That(dictionary, Does.ContainKey("a").WithValue(123).And.ContainKey("c").WithValue(456), "Fails but for the wrong reason");
});
}
}

0 comments on commit bf0381c

Please sign in to comment.