@@ -155,50 +155,96 @@ private void TestDelete()
155155 Assert . AreEqual ( HttpStatusCode . NoContent , response . StatusCode ) ;
156156 }
157157
158- [ TestFixture ]
159- public class Suppressions
158+ }
159+
160+ [ TestFixture ]
161+ public class Suppressions
162+ {
163+ static string _baseUri = "https://api.sendgrid.com/" ;
164+ static string _apiKey = Environment . GetEnvironmentVariable ( "SENDGRID_APIKEY" ) ;
165+ public Client client = new Client ( _apiKey , _baseUri ) ;
166+
167+ [ Test ]
168+ public void SuppressionsIntegrationTest ( )
160169 {
161- static string _baseUri = "https://api.sendgrid.com/" ;
162- static string _apiKey = Environment . GetEnvironmentVariable ( "SENDGRID_APIKEY" ) ;
163- public Client client = new Client ( _apiKey , _baseUri ) ;
170+ int unsubscribeGroupId = 69 ;
164171
165- [ Test ]
166- public void SuppressionsIntegrationTest ( )
167- {
168- int unsubscribeGroupId = 69 ;
172+ TestGet ( unsubscribeGroupId ) ;
173+ 174+ TestPost ( unsubscribeGroupId , emails ) ;
175+ TestDelete ( unsubscribeGroupId , "[email protected] " ) ; 176+ TestDelete ( unsubscribeGroupId , "[email protected] " ) ; 177+ }
169178
170- TestGet ( unsubscribeGroupId ) ;
171- 172- TestPost ( unsubscribeGroupId , emails ) ;
173- TestDelete ( unsubscribeGroupId , "[email protected] " ) ; 174- TestDelete ( unsubscribeGroupId , "[email protected] " ) ; 175- }
179+ private void TestGet ( int unsubscribeGroupId )
180+ {
181+ HttpResponseMessage response = client . Suppressions . Get ( unsubscribeGroupId ) . Result ;
182+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
183+ string rawString = response . Content . ReadAsStringAsync ( ) . Result ;
184+ dynamic jsonObject = JsonConvert . DeserializeObject ( rawString ) ;
185+ Assert . IsNotNull ( jsonObject ) ;
186+ }
176187
177- private void TestGet ( int unsubscribeGroupId )
178- {
179- HttpResponseMessage response = client . Suppressions . Get ( unsubscribeGroupId ) . Result ;
180- Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
181- string rawString = response . Content . ReadAsStringAsync ( ) . Result ;
182- dynamic jsonObject = JsonConvert . DeserializeObject ( rawString ) ;
183- Assert . IsNotNull ( jsonObject ) ;
184- }
188+ private void TestPost ( int unsubscribeGroupId , string [ ] emails )
189+ {
190+ HttpResponseMessage response = client . Suppressions . Post ( unsubscribeGroupId , emails ) . Result ;
191+ Assert . AreEqual ( HttpStatusCode . Created , response . StatusCode ) ;
192+ string rawString = response . Content . ReadAsStringAsync ( ) . Result ;
193+ dynamic jsonObject = JObject . Parse ( rawString ) ;
194+ string recipient_emails = jsonObject . recipient_emails . ToString ( ) ;
195+ Assert . IsNotNull ( recipient_emails ) ;
196+ }
185197
186- private void TestPost ( int unsubscribeGroupId , string [ ] emails )
187- {
188- HttpResponseMessage response = client . Suppressions . Post ( unsubscribeGroupId , emails ) . Result ;
189- Assert . AreEqual ( HttpStatusCode . Created , response . StatusCode ) ;
190- string rawString = response . Content . ReadAsStringAsync ( ) . Result ;
191- dynamic jsonObject = JObject . Parse ( rawString ) ;
192- string recipient_emails = jsonObject . recipient_emails . ToString ( ) ;
193- Assert . IsNotNull ( recipient_emails ) ;
194- }
198+ private void TestDelete ( int unsubscribeGroupId , string email )
199+ {
200+ HttpResponseMessage response = client . Suppressions . Delete ( unsubscribeGroupId , email ) . Result ;
201+ Assert . AreEqual ( HttpStatusCode . NoContent , response . StatusCode ) ;
202+ }
195203
196- private void TestDelete ( int unsubscribeGroupId , string email )
197- {
198- HttpResponseMessage response = client . Suppressions . Delete ( unsubscribeGroupId , email ) . Result ;
199- Assert . AreEqual ( HttpStatusCode . NoContent , response . StatusCode ) ;
200- }
204+ }
205+
206+ [ TestFixture ]
207+ public class GlobalSuppressions
208+ {
209+ static string _baseUri = "https://api.sendgrid.com/" ;
210+ static string _apiKey = Environment . GetEnvironmentVariable ( "SENDGRID_APIKEY" ) ;
211+ public Client client = new Client ( _apiKey , _baseUri ) ;
212+
213+ [ Test ]
214+ public void SuppressionsIntegrationTest ( )
215+ {
216+ string email = "[email protected] " ; 217+
218+ TestGet ( email ) ;
219+ 220+ TestPost ( emails ) ;
221+ 222+ 223+ }
201224
225+ private void TestGet ( string email )
226+ {
227+ HttpResponseMessage response = client . GlobalSuppressions . Get ( email ) . Result ;
228+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
229+ string rawString = response . Content . ReadAsStringAsync ( ) . Result ;
230+ dynamic jsonObject = JsonConvert . DeserializeObject ( rawString ) ;
231+ Assert . IsNotNull ( jsonObject ) ;
232+ }
233+
234+ private void TestPost ( string [ ] emails )
235+ {
236+ HttpResponseMessage response = client . GlobalSuppressions . Post ( emails ) . Result ;
237+ Assert . AreEqual ( HttpStatusCode . Created , response . StatusCode ) ;
238+ string rawString = response . Content . ReadAsStringAsync ( ) . Result ;
239+ dynamic jsonObject = JObject . Parse ( rawString ) ;
240+ string recipient_emails = jsonObject . recipient_emails . ToString ( ) ;
241+ Assert . IsNotNull ( recipient_emails ) ;
242+ }
243+
244+ private void TestDelete ( string email )
245+ {
246+ HttpResponseMessage response = client . GlobalSuppressions . Delete ( email ) . Result ;
247+ Assert . AreEqual ( HttpStatusCode . NoContent , response . StatusCode ) ;
202248 }
203249
204250 }
0 commit comments