コード例 #1
0
        public async Task <IActionResult> GetBanks(string lppId)
        {
            object response;

            try
            {
                if (lppId == "eps")
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", apiOptions.PublicKey);
                    HttpResponseMessage result = await client.GetAsync($"{apiOptions.GatewayUri}/giropay/eps/banks");

                    string content = await result.Content.ReadAsStringAsync();

                    BanksResponse banksResponse = JsonConvert.DeserializeObject <BanksResponse>(content);
                    response = banksResponse;
                }
                else if (lppId == "giropay")
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", apiOptions.PublicKey);
                    HttpResponseMessage result = await client.GetAsync($"{apiOptions.GatewayUri}/giropay/banks");

                    string content = await result.Content.ReadAsStringAsync();

                    BanksResponse banksResponse = JsonConvert.DeserializeObject <BanksResponse>(content);
                    response = banksResponse;
                }
                else if (lppId == "ideal")
                {
                    client.DefaultRequestHeaders.Clear();
                    client.DefaultRequestHeaders.Add("Authorization", apiOptions.PublicKey);
                    HttpResponseMessage result = await client.GetAsync($"{apiOptions.GatewayUri}/ideal-external/issuers");

                    string content = await result.Content.ReadAsStringAsync();

                    IssuersResponse issuersResponse = JsonConvert.DeserializeObject <IssuersResponse>(content);
                    response = issuersResponse;
                }
                else
                {
                    throw new KeyNotFoundException();
                }
                return(Ok(response));
            }
            catch (Exception e)
            {
                return(NotFound(e.Message));
            }
        }
コード例 #2
0
        void when_get_banks()
        {
            context["given ~/ideal/banks"] = () =>
            {
                beforeAllAsync = async() =>
                {
                    lppId  = "ideal";
                    result = await controller.GetBanks(lppId);

                    legacyBanks = (result as ObjectResult).Value as IssuersResponse;
                };

                it["should return 200 - OK"] = () =>
                {
                    (result as OkObjectResult).StatusCode.ShouldBe(StatusCodes.Status200OK);
                };

                it["should return a non-empty list of legacy typed banks"] = () =>
                {
                    legacyBanks.Countries.ShouldNotBeNull();
                };

                it["should contain single legacy typed bank with name 'Issuer Simulation V3 - ING' and bic 'INGBNL2A'"] = () =>
                {
                    legacyBanks.Countries.Single(country => (country.Issuers.First().Name == "Issuer Simulation V3 - ING" && country.Issuers.First().Bic == "INGBNL2A"));
                };
            };

            context["given ~/giropay/banks"] = () =>
            {
                beforeAllAsync = async() =>
                {
                    lppId  = "giropay";
                    result = await controller.GetBanks(lppId);

                    banks = (result as ObjectResult).Value as BanksResponse;
                };

                it["should return 200 - OK"] = () =>
                {
                    (result as OkObjectResult).StatusCode.ShouldBe(StatusCodes.Status200OK);
                };

                it["should return True for property 'HasBanks'"] = () =>
                {
                    banks.HasBanks.ShouldBeTrue();
                };

                it["should return a type of Dictionary<string, string> for property 'Banks'"] = () =>
                {
                    banks.Banks.ShouldBeOfType <Dictionary <string, string> >();
                };

                it["should return a non-empty Dictionary for property 'Banks'"] = () =>
                {
                    banks.Banks.Count.ShouldBeGreaterThan(0);
                };

                it["should contain KeyValuePair 'TESTDETT421': 'giropay Testinstitut'"] = () =>
                {
                    banks.Banks.ShouldContainKeyAndValue("TESTDETT421", "giropay Testinstitut");
                };
            };

            context["given ~/ducks/banks"] = () =>
            {
                beforeAllAsync = async() =>
                {
                    lppId  = "ducks";
                    result = await controller.GetBanks(lppId);
                };

                it["should return 404 - Not Found"] = () =>
                {
                    (result as NotFoundObjectResult).StatusCode.ShouldBe(StatusCodes.Status404NotFound);
                };
            };
        }