Skip to content

Commit

Permalink
Fix code in Readme to use ContainsKey (#16)
Browse files Browse the repository at this point in the history
There was an error in the code snippet presented in the readme. Instead
of `Contains(.)`, `ContainsKey(.)` should be used when checking for
specs.
  • Loading branch information
mristin authored Jun 4, 2021
1 parent f39ef11 commit 4462bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ byte[] supplementaryContent;

// Read the specs
var specsByContentType = pkg.SpecsByContentType();
if (!specsByContentType.Contains("text/json"))
if (!specsByContentType.ContainsKey("text/json"))
{
throw new ArgumentException("No json specs");
}
Expand Down
4 changes: 4 additions & 0 deletions src/AasCore.Aas3.Package.Tests/TestPackageRead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ public void Test_grouping_specs_by_content_type()
Assert.That(specsByContentType.Keys.ToList(),
Is.EquivalentTo(new List<string> { "text/json", "text/xml" }));

// Test this for the Readme.
Assert.That(specsByContentType.ContainsKey("text/json"));
Assert.That(specsByContentType.ContainsKey("text/xml"));

foreach (var item in specsByContentType)
{
var contentType = item.Key;
Expand Down

0 comments on commit 4462bd2

Please sign in to comment.