Skip to content
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
28 changes: 0 additions & 28 deletions test/Microsoft.OpenApi.Readers.Tests/DefaultSettingsFixture.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<ItemGroup>
<PackageReference Include="coverlet.MTP" Version="10.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.9.0" />
<PackageReference Include="FluentAssertions" Version="7.2.2" />
<PackageReference Include="xunit.v3" Version="4.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Tests;
using Xunit;

namespace Microsoft.OpenApi.Readers.Tests.V2Tests
Expand All @@ -27,8 +27,7 @@ public async Task EquivalentV2AndV3DocumentsShouldProduceEquivalentObjects(strin
var result1 = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, $"{fileName}.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var result2 = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, $"{fileName}.v3.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);

result2.Document.Should().BeEquivalentTo(result1.Document,
options => options.Excluding(x => x.Workspace).Excluding(y => y.BaseUri));
OpenApiTestAssert.Equivalent(result1.Document, result2.Document, nameof(OpenApiDocument.Workspace), nameof(OpenApiDocument.BaseUri));

Assert.Equivalent(result2.Diagnostic.Errors, result1.Diagnostic.Errors);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Tests;
using Xunit;

namespace Microsoft.OpenApi.Readers.Tests.V2Tests
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task ShouldParseProducesInAnyOrder()
Schema = new OpenApiSchemaReference("Error", result.Document)
};

result.Document.Should().BeEquivalentTo(new OpenApiDocument
OpenApiTestAssert.Equivalent(new OpenApiDocument
{
Info = new()
{
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task ShouldParseProducesInAnyOrder()
["Error"] = errorSchema
}
}
}, options => options.Excluding(x => x.BaseUri));
}, result.Document, nameof(OpenApiDocument.BaseUri));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@

using System.Text.Json.Nodes;
using System.IO;
using FluentAssertions;
using FluentAssertions.Equivalency;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Reader.V2;
using Microsoft.OpenApi.Tests;
using Xunit;

namespace Microsoft.OpenApi.Readers.Tests.V2Tests
Expand All @@ -30,7 +29,7 @@ public void ParseHeaderWithDefaultShouldSucceed()
var header = OpenApiV2Deserializer.LoadHeader(node, new(), new ParsingContext(new()));

// Assert
header.Should().BeEquivalentTo(
OpenApiTestAssert.Equivalent(
new OpenApiHeader
{
Schema = new OpenApiSchema()
Expand All @@ -40,9 +39,8 @@ public void ParseHeaderWithDefaultShouldSucceed()
Default = new JsonNodeExtension(5).Node
}
},
options => options
.IgnoringCyclicReferences()
.Excluding(x => x.Schema.Default.Parent));
header,
nameof(JsonNode.Parent));
}

[Fact]
Expand All @@ -59,7 +57,7 @@ public void ParseHeaderWithEnumShouldSucceed()
var header = OpenApiV2Deserializer.LoadHeader(node, new(), new ParsingContext(new()));

// Assert
header.Should().BeEquivalentTo(
OpenApiTestAssert.Equivalent(
new OpenApiHeader
{
Schema = new OpenApiSchema()
Expand All @@ -73,9 +71,7 @@ public void ParseHeaderWithEnumShouldSucceed()
new JsonNodeExtension(9).Node
]
}
}, options => options.IgnoringCyclicReferences()
.Excluding((IMemberInfo memberInfo) =>
memberInfo.Path.EndsWith("Parent")));
}, header, nameof(JsonNode.Parent));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Reader.V2;
using Microsoft.OpenApi.Reader.V3;
Expand Down Expand Up @@ -165,7 +164,7 @@ public void ParseOperationWithBodyShouldSucceed()
var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new()));

// Assert
operation.Should().BeEquivalentTo(_operationWithBody, options => options.IgnoringCyclicReferences());
OpenApiTestAssert.Equivalent(_operationWithBody, operation);
}

[Fact]
Expand All @@ -183,7 +182,7 @@ public async Task ParseOperationWithBodyTwiceShouldYieldSameObject()
var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new()));

// Assert
operation.Should().BeEquivalentTo(_operationWithBody, options => options.IgnoringCyclicReferences());
OpenApiTestAssert.Equivalent(_operationWithBody, operation);
}

[Fact]
Expand All @@ -200,7 +199,7 @@ public void ParseOperationWithResponseExamplesShouldSucceed()
var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new()));

// Assert
operation.Should().BeEquivalentTo(
OpenApiTestAssert.Equivalent(
new OpenApiOperation()
{
Responses = new OpenApiResponses()
Expand Down Expand Up @@ -243,13 +242,7 @@ public void ParseOperationWithResponseExamplesShouldSucceed()
}
}}
}
}, options => options.IgnoringCyclicReferences()
.Excluding(o => o.Responses["200"].Content["application/json"].Example[0].Parent)
.Excluding(o => o.Responses["200"].Content["application/json"].Example[0].Root)
.Excluding(o => o.Responses["200"].Content["application/json"].Example[1].Parent)
.Excluding(o => o.Responses["200"].Content["application/json"].Example[1].Root)
.Excluding(o => o.Responses["200"].Content["application/json"].Example[2].Parent)
.Excluding(o => o.Responses["200"].Content["application/json"].Example[2].Root));
}, operation, nameof(JsonNode.Parent), nameof(JsonNode.Root));
}

[Fact]
Expand Down Expand Up @@ -300,7 +293,7 @@ public void ParseOperationWithBodyAndEmptyConsumesSetsRequestBodySchemaIfExists(
var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new()));

// Assert
operation.Should().BeEquivalentTo(_operationWithBody, options => options.IgnoringCyclicReferences());
OpenApiTestAssert.Equivalent(_operationWithBody, operation);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Licensed under the MIT license.

using System.IO;
using FluentAssertions;
using FluentAssertions.Equivalency;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Reader.V2;
using Microsoft.OpenApi.Tests;
Expand Down Expand Up @@ -226,7 +224,7 @@ public void ParseParameterWithDefaultShouldSucceed()
var parameter = OpenApiV2Deserializer.LoadParameter(node, new(), new ParsingContext(new()));

// Assert
parameter.Should().BeEquivalentTo(
OpenApiTestAssert.Equivalent(
new OpenApiParameter
{
In = ParameterLocation.Path,
Expand All @@ -239,7 +237,7 @@ public void ParseParameterWithDefaultShouldSucceed()
Format = "float",
Default = new JsonNodeExtension(5).Node
}
}, options => options.IgnoringCyclicReferences().Excluding(x => x.Schema.Default.Parent));
}, parameter, nameof(JsonNode.Parent));
}

[Fact]
Expand Down Expand Up @@ -274,10 +272,7 @@ public void ParseParameterWithEnumShouldSucceed()
};

// Assert
parameter.Should().BeEquivalentTo(expected, options => options
.IgnoringCyclicReferences()
.Excluding((IMemberInfo memberInfo) =>
memberInfo.Path.EndsWith("Parent")));
OpenApiTestAssert.Equivalent(expected, parameter, nameof(JsonNode.Parent));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System.IO;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using FluentAssertions;
using FluentAssertions.Equivalency;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Reader.V2;
using Microsoft.OpenApi.Tests;
Expand Down Expand Up @@ -35,12 +33,12 @@ public void ParseSchemaWithDefaultShouldSucceed()
var schema = OpenApiV2Deserializer.LoadSchema(node, new(), new ParsingContext(new()));

// Assert
schema.Should().BeEquivalentTo(new OpenApiSchema
OpenApiTestAssert.Equivalent(new OpenApiSchema
{
Type = JsonSchemaType.Number,
Format = "float",
Default = 5
}, options => options.IgnoringCyclicReferences().Excluding(x => x.Default.Parent));
}, schema, nameof(JsonNode.Parent));
}

[Fact]
Expand All @@ -57,13 +55,13 @@ public void ParseSchemaWithExampleShouldSucceed()
var schema = OpenApiV2Deserializer.LoadSchema(node, new(), new ParsingContext(new()));

// Assert
schema.Should().BeEquivalentTo(
OpenApiTestAssert.Equivalent(
new OpenApiSchema
{
Type = JsonSchemaType.Number,
Format = "float",
Example = 5
}, options => options.IgnoringCyclicReferences().Excluding(x => x.Example.Parent));
}, schema, nameof(JsonNode.Parent));
}

[Fact]
Expand Down Expand Up @@ -92,10 +90,7 @@ public void ParseSchemaWithEnumShouldSucceed()
]
};

schema.Should().BeEquivalentTo(expected, options =>
options.IgnoringCyclicReferences()
.Excluding((IMemberInfo memberInfo) =>
memberInfo.Path.EndsWith("Parent")));
OpenApiTestAssert.Equivalent(expected, schema, nameof(JsonNode.Parent));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Globalization;
using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.OpenApi.Reader;
using Microsoft.OpenApi.Tests;
using Xunit;
Expand Down Expand Up @@ -244,7 +243,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed()

// Assert
Assert.Equivalent(new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_1, Format = OpenApiConstants.Yaml }, actual.Diagnostic);
actual.Document.Should().BeEquivalentTo(expected, options => options.Excluding(x => x.Workspace).Excluding(y => y.BaseUri));
OpenApiTestAssert.Equivalent(expected, actual.Document, nameof(OpenApiDocument.Workspace), nameof(OpenApiDocument.BaseUri));
}

[Fact]
Expand Down Expand Up @@ -446,9 +445,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds()
};

// Assert
actual.Document.Should().BeEquivalentTo(expected, options => options
.Excluding(x => x.Workspace)
.Excluding(y => y.BaseUri));
OpenApiTestAssert.Equivalent(expected, actual.Document, nameof(OpenApiDocument.Workspace), nameof(OpenApiDocument.BaseUri));
Assert.Equivalent(
new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_1, Format = OpenApiConstants.Yaml }, actual.Diagnostic);
}
Expand Down Expand Up @@ -613,7 +610,7 @@ public async Task ParseDocumentWithEmptyTagsWorks()
var path = Path.Join(SampleFolderPath, "documentWithEmptyTags.json");
var doc = (await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;

doc.Paths["/groups"].Operations[HttpMethod.Get].Tags.Should().BeNull("Empty tags are ignored, so we should not have any tags");
Assert.Null(doc.Paths["/groups"].Operations[HttpMethod.Get].Tags);
}
[Fact]
public async Task DocumentWithSchemaResultsInWarning()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using FluentAssertions;
using Microsoft.OpenApi.Reader;
using Xunit;

Expand Down
Loading
Loading