summaryrefslogtreecommitdiffstats
path: root/SendGrid/Tests/Transport/TestErrorChecker.cs
diff options
context:
space:
mode:
authorHoward van Rooijen <Howard.vanRooijen@endjin.com>2015-02-04 21:49:29 +0000
committerHoward van Rooijen <Howard.vanRooijen@endjin.com>2015-02-06 07:23:55 +0000
commit2705013d2b58d0e614205606c87c4ad2ecec8259 (patch)
tree93e610e85a2bf722bc0ce2581a42e386e84ccf2a /SendGrid/Tests/Transport/TestErrorChecker.cs
parent6354302c92e8994b44ae8fc89a992ad4ffca5b6d (diff)
downloadsendgrid-csharp-2705013d2b58d0e614205606c87c4ad2ecec8259.zip
sendgrid-csharp-2705013d2b58d0e614205606c87c4ad2ecec8259.tar.gz
sendgrid-csharp-2705013d2b58d0e614205606c87c4ad2ecec8259.tar.bz2
Refactor error handling. Add test for checking for bad username / password scenario
Diffstat (limited to 'SendGrid/Tests/Transport/TestErrorChecker.cs')
-rw-r--r--SendGrid/Tests/Transport/TestErrorChecker.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/SendGrid/Tests/Transport/TestErrorChecker.cs b/SendGrid/Tests/Transport/TestErrorChecker.cs
new file mode 100644
index 0000000..f178064
--- /dev/null
+++ b/SendGrid/Tests/Transport/TestErrorChecker.cs
@@ -0,0 +1,34 @@
+namespace Transport
+{
+ #region Using Directives
+
+ using System;
+ using System.Net;
+ using System.Net.Http;
+
+ using Exceptions;
+
+ using NUnit.Framework;
+
+ using SendGrid;
+
+ #endregion
+
+ [TestFixture]
+ public class TestErrorChecker
+ {
+ private const string BadUsernameOrPasswordResponseMessage = "<result><message>error</message><errors><error>Bad username / password</error></errors></result>";
+
+ [Test]
+ [ExpectedException(typeof(InvalidApiRequestException))]
+ public void WhenHttpResponseContainsBadUserErrorItIsDetectedAndAInvalidApiRequestIsThrown()
+ {
+ var response = new HttpResponseMessage(HttpStatusCode.BadRequest)
+ {
+ Content = new StringContent(BadUsernameOrPasswordResponseMessage)
+ };
+
+ ErrorChecker.CheckForErrors(response);
+ }
+ }
+} \ No newline at end of file