Exemple #1
0
        public void Should_throw_unrecognised_error_exception_when_creating_non_api_error_exception_with_5xxx_code()
        {
            var dummyResponse = new Response(HttpStatusCode.BadRequest, "Test Body");
            var error         = new Error {
                Code = 5001
            };

            Assert.Throws <UnrecognisedErrorException>(() => ExceptionFactory.CreateApiErrorException(error, dummyResponse));
        }
Exemple #2
0
        public void Should_create_user_card_exception_when_creating_non_api_error_exception_with_3xxx_code()
        {
            var dummyResponse = new Response(HttpStatusCode.BadRequest, "Test Body");
            var error         = new Error {
                Code = 3001
            };
            var result = ExceptionFactory.CreateApiErrorException(error, dummyResponse);

            Assert.That(result, Is.TypeOf <UserCardException>());
        }
Exemple #3
0
        public void Should_create_invalid_parameter_exception_when_creating_non_api_error_exception_with_1xxx_code()
        {
            var dummyResponse = new Response(HttpStatusCode.BadRequest, "Test Body");
            var error         = new Error {
                Code = 1001
            };
            var result = ExceptionFactory.CreateApiErrorException(error, dummyResponse);

            Assert.That(result, Is.TypeOf <InputParameterException>());
        }
Exemple #4
0
        public void Should_set_properties_when_creating_non_api_error_exception()
        {
            var dummyResponse = new Response(HttpStatusCode.BadRequest, "Test Body");
            var error         = new Error {
                Code = 1001
            };
            var result = ExceptionFactory.CreateApiErrorException(error, dummyResponse);

            Assert.That(result.ResponseBody, Is.EqualTo(dummyResponse.Body));
            Assert.That(result.StatusCode, Is.EqualTo(dummyResponse.StatusCode));
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.RequiredParameterMissing));
        }