コード例 #1
0
        public async void TestResponseStateCodesExceptions(ResponseStateCode code, Type exception)
        {
            // ARRANGE
            dynamic responseMessage = new JObject();

            responseMessage.tilaKoodi       = code;
            responseMessage.tilaKoodiKuvaus = "TestiKuvaus";
            responseMessage.sanomaTunniste  = "123-123";

            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(responseMessage.ToString())
            };
            var client = GetClient(mockResponse);

            // ACT
            var thrownException = await Record.ExceptionAsync(() => client.CustomerHasAccount("123456-7890"));

            // ASSERT
            Assert.NotNull(thrownException);
            Assert.Equal(thrownException.GetType(), exception);
        }
コード例 #2
0
        /// <summary>
        /// Description messages copied from https://www.joinex.com/sites/mip.io/mip.io-asti/index.html
        /// </summary>
        internal static bool HandleResponseStateCode(ResponseStateCode code)
        {
            switch (code)
            {
            case ResponseStateCode.Success: return(true);

            case ResponseStateCode.FalseDataError: throw new FalseDataException();

            case ResponseStateCode.WrongAuthError: throw new AuthorizationException();

            case ResponseStateCode.NotMatchingIdsError: throw new NotMatchingIdsException();

            case ResponseStateCode.NotAllowedError: throw new ActionNotAllowedException();

            case ResponseStateCode.FalseSignatureError: throw new FalseSignatureException();

            case ResponseStateCode.OtherError: throw new OtherException();

            case ResponseStateCode.ConnectionError: throw new ConnectionException();
            }
            return(true);
        }