-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #892 from matt9ucci/contact-fragment
Add OpenApiContact for ReadFragment
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiContactTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FluentAssertions; | ||
using Microsoft.OpenApi.Models; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V2Tests | ||
{ | ||
public class OpenApiContactTests | ||
{ | ||
[Fact] | ||
public void ParseStringContactFragmentShouldSucceed() | ||
{ | ||
var input = @" | ||
{ | ||
""name"": ""API Support"", | ||
""url"": ""http://www.swagger.io/support"", | ||
""email"": ""[email protected]"" | ||
} | ||
"; | ||
var reader = new OpenApiStringReader(); | ||
var diagnostic = new OpenApiDiagnostic(); | ||
|
||
// Act | ||
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic); | ||
|
||
// Assert | ||
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); | ||
|
||
contact.Should().BeEquivalentTo( | ||
new OpenApiContact | ||
{ | ||
Email = "[email protected]", | ||
Name = "API Support", | ||
Url = new Uri("http://www.swagger.io/support") | ||
}); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiContactTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. | ||
|
||
using FluentAssertions; | ||
using Microsoft.OpenApi.Models; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Microsoft.OpenApi.Readers.Tests.V3Tests | ||
{ | ||
public class OpenApiContactTests | ||
{ | ||
[Fact] | ||
public void ParseStringContactFragmentShouldSucceed() | ||
{ | ||
var input = @" | ||
{ | ||
""name"": ""API Support"", | ||
""url"": ""http://www.swagger.io/support"", | ||
""email"": ""[email protected]"" | ||
} | ||
"; | ||
var reader = new OpenApiStringReader(); | ||
var diagnostic = new OpenApiDiagnostic(); | ||
|
||
// Act | ||
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic); | ||
|
||
// Assert | ||
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic()); | ||
|
||
contact.Should().BeEquivalentTo( | ||
new OpenApiContact | ||
{ | ||
Email = "[email protected]", | ||
Name = "API Support", | ||
Url = new Uri("http://www.swagger.io/support") | ||
}); | ||
} | ||
} | ||
} |