Skip to content

Commit

Permalink
feat: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dec.kolakowski committed Apr 19, 2024
1 parent 8908ace commit fe2c81b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) The LEGO Group. All rights reserved.

using FluentAssertions;

namespace LEGO.AsyncAPI.Tests
{
using System;
Expand Down Expand Up @@ -591,5 +593,42 @@ public void Read_WithBasicPlusSecurityRequirementsDeserializes()
Assert.IsTrue(requirement.Value.Contains("write:pets"));
Assert.IsTrue(requirement.Value.Contains("read:pets"));
}

[Test]
public void Read_WithExternalResourcesInterfaceDeserializes()
{
var yaml = """
asyncapi: 2.3.0
info:
title: test
version: 1.0.0
channels:
workspace:
publish:
message:
$ref: "./some/path/to/external/resource.yaml"
""";
var settings = new AsyncApiReaderSettings
{
ExternalReferenceReader = new MockExternalReferenceReader(),
};
var reader = new AsyncApiStringReader(settings);
var doc = reader.Read(yaml, out var diagnostic);
doc.Info.Title.Should().Be("test");
}
}

public class MockExternalReferenceReader : IAsyncApiExternalReferenceReader
{
public string GetExternalResource(string reference)
{
return """
name: Test
title: Test message
summary: Test.
schemaFormat: application/schema+yaml;version=draft-07
contentType: application/cloudevents+json
""";
}
}
}

0 comments on commit fe2c81b

Please sign in to comment.