Пример #1
0
        public async Task <List <Transaction> > GetTransactions(string lowellRef)
        {
            var url = $"{_portalSettings.GatewayEndpoint}api/ViewTransactions/GetTransactions";

            ApiAccountReferenceModel accountRef = new ApiAccountReferenceModel()
            {
                AccountReference = lowellRef
            };

            ApiTransactionsWrapper result = await _restClient.PostAsync <ApiAccountReferenceModel, ApiTransactionsWrapper>(url, accountRef);

            if (result != null)
            {
                return(_mapper.Map <List <ApiTransaction>, List <Transaction> >(result.Payments));
            }

            return(null);
        }
Пример #2
0
        public async Task GetTransactionsTest()
        {
            string lowellRef = "12345678";
            string uri       = $"{_portalSettings.GatewayEndpoint}api/ViewTransactions/GetTransactions";

            ApiTransactionsWrapper apiModel = new ApiTransactionsWrapper()
            {
                Payments = new List <ApiTransaction>()
                {
                    new ApiTransaction()
                    {
                        Amount         = 111.11M,
                        Date           = DateTime.Now.AddDays(-180),
                        Description    = "Description1",
                        Type           = "Type1",
                        RollingBalance = 999.99M
                    },
                    new ApiTransaction()
                    {
                        Amount         = 222.22M,
                        Date           = DateTime.Now.AddDays(-150),
                        Description    = "Description2",
                        Type           = "Type2",
                        RollingBalance = 888.88M
                    },
                    new ApiTransaction()
                    {
                        Amount         = 333.33M,
                        Date           = DateTime.Now.AddDays(-120),
                        Description    = "Description3",
                        Type           = "Type3",
                        RollingBalance = 777.77M
                    },
                    new ApiTransaction()
                    {
                        Amount         = 444.44M,
                        Date           = DateTime.Now.AddDays(-90),
                        Description    = "Description4",
                        Type           = "Type4",
                        RollingBalance = 666.66M
                    },
                    new ApiTransaction()
                    {
                        Amount         = 333.33M,
                        Date           = DateTime.Now.AddDays(-60),
                        Description    = "Description5",
                        Type           = "Type5",
                        RollingBalance = 555.55M
                    },
                }
            };

            List <Transaction> serviceModel = new List <Transaction>()
            {
                new Transaction()
                {
                    Amount         = 111.11M,
                    Date           = DateTime.Now.AddDays(-180),
                    Description    = "Description1",
                    Type           = "Type1",
                    RollingBalance = 999.99M
                },
                new Transaction()
                {
                    Amount         = 222.22M,
                    Date           = DateTime.Now.AddDays(-150),
                    Description    = "Description2",
                    Type           = "Type2",
                    RollingBalance = 888.88M
                },
                new Transaction()
                {
                    Amount         = 333.33M,
                    Date           = DateTime.Now.AddDays(-120),
                    Description    = "Description3",
                    Type           = "Type3",
                    RollingBalance = 777.77M
                },
                new Transaction()
                {
                    Amount         = 444.44M,
                    Date           = DateTime.Now.AddDays(-90),
                    Description    = "Description4",
                    Type           = "Type4",
                    RollingBalance = 666.66M
                },
                new Transaction()
                {
                    Amount         = 333.33M,
                    Date           = DateTime.Now.AddDays(-60),
                    Description    = "Description5",
                    Type           = "Type5",
                    RollingBalance = 555.55M
                },
            };

            this._restClient.Setup(x =>
                                   x.PostAsync <ApiAccountReferenceModel, ApiTransactionsWrapper>(uri, It.Is <ApiAccountReferenceModel>(m =>
                                                                                                                                        m.AccountReference == "12345678"))).Returns(Task.FromResult(apiModel));
            this._mapper.Setup(x => x.Map <List <ApiTransaction>, List <Transaction> >(apiModel.Payments)).Returns(serviceModel);

            List <Transaction> result = await _service.GetTransactions(lowellRef);

            string expectedString = JsonConvert.SerializeObject(serviceModel);
            string resultString   = JsonConvert.SerializeObject(result);

            Assert.AreEqual(expectedString, resultString);
        }