File tree Expand file tree Collapse file tree
test/ByteBard.AsyncAPI.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace ByteBard . AsyncAPI . Tests ;
2+ using NUnit . Framework ;
3+ using Readers ;
4+
5+ public class SchemaParserRegistryTests
6+ {
7+ private SchemaParserRegistry registry ;
8+
9+ public SchemaParserRegistryTests ( )
10+ {
11+ this . registry = new SchemaParserRegistry ( ) ;
12+ }
13+
14+ [ Test ]
15+ public void GetParser_WithNullFormat_ReturnsJsonSchemaParser ( )
16+ {
17+ // Arrange
18+ // Act
19+ var result = this . registry . GetParser ( null ) ;
20+
21+ // Assert
22+ Assert . IsNotNull ( result ) ;
23+ Assert . True ( result is JsonSchemaParser ) ;
24+ }
25+
26+ [ Test ]
27+ public void GetParser_WithEmptyFormat_ReturnsJsonSchemaParser ( )
28+ {
29+ // Arrange
30+ // Act
31+ var result = this . registry . GetParser ( string . Empty ) ;
32+
33+ // Assert
34+ Assert . IsNotNull ( result ) ;
35+ Assert . True ( result is JsonSchemaParser ) ;
36+ }
37+
38+ [ Test ]
39+ public void GetParser_WithExactKeyMatch_ReturnsCorrectParser ( )
40+ {
41+ // Arrange
42+ // Act
43+ var result = this . registry . GetParser ( "application/vnd.aai.asyncapi+json" ) ;
44+
45+ // Assert
46+ Assert . IsNotNull ( result ) ;
47+ }
48+
49+ [ Test ]
50+ public void GetParser_WithPrefixMatch_ReturnsCorrectParser ( )
51+ {
52+ // Arrange
53+ // Act
54+ var result = this . registry . GetParser ( "application/vnd.aai.asyncapi+json;charset=utf-8" ) ;
55+
56+ // Assert
57+ Assert . IsNotNull ( result ) ;
58+ }
59+
60+ [ Test ]
61+ public void GetParser_WithUnknownFormat_ReturnsNull ( )
62+ {
63+ // Arrange
64+ // Act
65+ var result = this . registry . GetParser ( "application/unknown+format" ) ;
66+
67+ // Assert
68+ Assert . IsNull ( result ) ;
69+ }
70+
71+ [ Test ]
72+ public void GetParser_WithNonMatchingPrefix_ReturnsNull ( )
73+ {
74+ // Arrange
75+ // Act
76+ var result = this . registry . GetParser ( "text/plain" ) ;
77+
78+ // Assert
79+ Assert . IsNull ( result ) ;
80+ }
81+ }
You can’t perform that action at this time.
0 commit comments