@@ -18,9 +18,11 @@ public class NotificationUrlTest : BunqSdkTestBase
18
18
private const string GET_PAYMENT = "Payment" ;
19
19
private const string GET_BUNQ_ME_TAB = "BunqMeTab" ;
20
20
private const string GET_CHAT_MESSAGE_ANNOUNCEMENT = "ChatMessageAnnouncement" ;
21
+ private const string GET_CHAT_MESSAGE = "ChatMessage" ;
21
22
private const string GET_DRAFT_PAYMENT = "DraftPayment" ;
22
23
private const string GET_MASTER_CARD_ACTION = "MasterCardAction" ;
23
24
private const string GET_MONETARY_ACCOUNT_BANK = "MonetaryAccountBank" ;
25
+ private const string GET_MONETARY_ACCOUNT = "MonetaryAccount" ;
24
26
private const string GET_PAYMENT_BATCH = "PaymentBatch" ;
25
27
private const string GET_REQUEST_INQUIRY = "RequestInquiry" ;
26
28
private const string GET_REQUEST_RESPONSE = "RequestResponse" ;
@@ -58,23 +60,33 @@ public class NotificationUrlTest : BunqSdkTestBase
58
60
59
61
private void ExecuteNotificationUrlTest (
60
62
string expectedJsonFileName ,
61
- Type classNameExpected ,
62
- string referencedObjectPropertyName
63
- ) {
63
+ Type classTypeExpected ,
64
+ string referencedObjectPropertyName ,
65
+ string subClassObjectPropertyName = null ,
66
+ Type subClassTypeExpected = null )
67
+ {
64
68
var jsonString = ReadJsonFromFile ( expectedJsonFileName ) ;
65
- var notificationUrl = BunqModel . CreateFromJsonString < NotificationUrl > ( jsonString ) ;
69
+ var notificationUrl = NotificationUrl . CreateFromJsonString ( jsonString ) ;
66
70
67
71
Assert . NotNull ( notificationUrl ) ;
68
72
Assert . NotNull ( notificationUrl . Object ) ;
69
73
70
- var model = notificationUrl . Object . GetType ( ) . GetProperty ( referencedObjectPropertyName ) . GetValue (
71
- notificationUrl . Object ) ;
74
+ var model = notificationUrl . Object . GetType ( )
75
+ . GetProperty ( referencedObjectPropertyName )
76
+ . GetValue ( notificationUrl . Object ) ;
72
77
var referencedModel = notificationUrl . Object . GetReferencedObject ( ) ;
73
78
74
79
Assert . NotNull ( model ) ;
75
80
Assert . NotNull ( referencedModel ) ;
76
- Assert . IsType ( classNameExpected , referencedModel ) ;
77
- Assert . Equal ( classNameExpected , referencedModel . GetType ( ) ) ;
81
+ Assert . IsType ( classTypeExpected , referencedModel ) ;
82
+
83
+ if ( subClassObjectPropertyName == null || subClassTypeExpected == null ) return ;
84
+ var subClass = referencedModel . GetType ( )
85
+ . GetProperty ( subClassObjectPropertyName )
86
+ . GetValue ( referencedModel ) ;
87
+
88
+ Assert . NotNull ( subClass ) ;
89
+ Assert . IsType ( subClassTypeExpected , subClass ) ;
78
90
}
79
91
80
92
private static string ReadJsonFromFile ( string fileName )
@@ -113,8 +125,10 @@ public void TestChatMessageAnnouncementModel()
113
125
{
114
126
ExecuteNotificationUrlTest (
115
127
JSON_PATH_CHAT_MESSAGE_ANNOUNCEMENT_MODEL ,
116
- typeof ( ChatMessageAnnouncement ) ,
117
- GET_CHAT_MESSAGE_ANNOUNCEMENT
128
+ typeof ( ChatMessage ) ,
129
+ GET_CHAT_MESSAGE ,
130
+ GET_CHAT_MESSAGE_ANNOUNCEMENT ,
131
+ typeof ( ChatMessageAnnouncement )
118
132
) ;
119
133
}
120
134
@@ -143,8 +157,10 @@ public void TestMonetaryAccountBankModel()
143
157
{
144
158
ExecuteNotificationUrlTest (
145
159
JSON_PATH_MONETARY_ACCOUNT_BANK_MODEL ,
146
- typeof ( MonetaryAccountBank ) ,
147
- GET_MONETARY_ACCOUNT_BANK
160
+ typeof ( MonetaryAccount ) ,
161
+ GET_MONETARY_ACCOUNT ,
162
+ GET_MONETARY_ACCOUNT_BANK ,
163
+ typeof ( MonetaryAccountBank )
148
164
) ;
149
165
}
150
166
0 commit comments