Skip to content

Commit ac4c73c

Browse files
committed
chore: initialize channels in tests first when needed, as it was removed from asyncApiDocument
1 parent 9b3c669 commit ac4c73c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

test/LEGO.AsyncAPI.Tests/AsyncApiDocumentBuilder.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace LEGO.AsyncAPI.Tests
44
{
5+
using System;
6+
using System.Collections.Generic;
57
using LEGO.AsyncAPI.Models;
68
using LEGO.AsyncAPI.Models.Interfaces;
7-
using System;
89

910
internal class AsyncApiDocumentBuilder
1011
{
@@ -42,6 +43,10 @@ public AsyncApiDocumentBuilder WithDefaultContentType(string contentType = "appl
4243

4344
public AsyncApiDocumentBuilder WithChannel(string key, AsyncApiChannel channel)
4445
{
46+
if (this.document.Channels == null)
47+
{
48+
this.document.Channels = new Dictionary<string, AsyncApiChannel>();
49+
}
4550
this.document.Channels.Add(key, channel);
4651
return this;
4752
}

test/LEGO.AsyncAPI.Tests/AsyncApiDocumentV2Tests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,10 @@ public void Serialize_WithBindingReferences_SerializesDeserializes()
12021202
},
12031203
},
12041204
};
1205+
if (doc.Channels == null)
1206+
{
1207+
doc.Channels = new Dictionary<string, AsyncApiChannel>();
1208+
}
12051209
doc.Channels.Add(
12061210
"testChannel",
12071211
new AsyncApiChannel
@@ -1260,6 +1264,10 @@ public void Serializev2_WithBindings_Serializes()
12601264
Protocol = "pulsar+ssl",
12611265
Url = "example.com",
12621266
});
1267+
if (doc.Channels == null)
1268+
{
1269+
doc.Channels = new Dictionary<string, AsyncApiChannel>();
1270+
}
12631271
doc.Channels.Add(
12641272
"testChannel",
12651273
new AsyncApiChannel

0 commit comments

Comments
 (0)