Skip to content

Commit fe2c81b

Browse files
author
dec.kolakowski
committed
feat: Add tests
1 parent 8908ace commit fe2c81b

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

‎test/LEGO.AsyncAPI.Tests/AsyncApiReaderTests.cs‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Copyright (c) The LEGO Group. All rights reserved.
22

3+
using FluentAssertions;
4+
35
namespace LEGO.AsyncAPI.Tests
46
{
57
using System;
@@ -591,5 +593,42 @@ public void Read_WithBasicPlusSecurityRequirementsDeserializes()
591593
Assert.IsTrue(requirement.Value.Contains("write:pets"));
592594
Assert.IsTrue(requirement.Value.Contains("read:pets"));
593595
}
596+
597+
[Test]
598+
public void Read_WithExternalResourcesInterfaceDeserializes()
599+
{
600+
var yaml = """
601+
asyncapi: 2.3.0
602+
info:
603+
title: test
604+
version: 1.0.0
605+
channels:
606+
workspace:
607+
publish:
608+
message:
609+
$ref: "./some/path/to/external/resource.yaml"
610+
""";
611+
var settings = new AsyncApiReaderSettings
612+
{
613+
ExternalReferenceReader = new MockExternalReferenceReader(),
614+
};
615+
var reader = new AsyncApiStringReader(settings);
616+
var doc = reader.Read(yaml, out var diagnostic);
617+
doc.Info.Title.Should().Be("test");
618+
}
619+
}
620+
621+
public class MockExternalReferenceReader : IAsyncApiExternalReferenceReader
622+
{
623+
public string GetExternalResource(string reference)
624+
{
625+
return """
626+
name: Test
627+
title: Test message
628+
summary: Test.
629+
schemaFormat: application/schema+yaml;version=draft-07
630+
contentType: application/cloudevents+json
631+
""";
632+
}
594633
}
595634
}

0 commit comments

Comments
 (0)