summaryrefslogtreecommitdiffstats
path: root/SendGrid/Tests/Transport/TestErrorChecker.cs
blob: f1780646f6110bd88fde1d7c21eaadd59b8f5ee3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);
        }
    }
}