Exemplo n.º 1
0
        /// <summary>
        /// Creates a list of batches directly from the API Response
        /// </summary>
        /// <param name="batches">The batches.</param>
        /// <returns></returns>
        public static List <Batch> NewFromResponse(getSettledBatchListResponse batches)
        {
            var result = new List <Batch>();

            if (null != batches && null != batches.batchList)
            {
                for (int i = 0; i < batches.batchList.Length; i++)
                {
                    var item = batches.batchList[i];

                    result.Add(new Batch
                    {
                        Charges       = Charge.NewFromStat(item.statistics),
                        ID            = item.batchId,
                        PaymentMethod = item.paymentMethod,
                        SettledOn     = item.settlementTimeUTC,
                        State         = item.settlementState,
                        MarketType    = item.marketType,
                        Product       = item.product
                    });
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public void MockgetSettledBatchListTest()
        {
            //define all mocked objects as final
            var mockController = GetMockController <getSettledBatchListRequest, getSettledBatchListResponse>();
            var mockRequest    = new getSettledBatchListRequest
            {
                merchantAuthentication = new merchantAuthenticationType {
                    name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey
                },
            };
            var batchDetailsType = new batchDetailsType[]
            {
                new batchDetailsType
                {
                    batchId = "1234",
                }
            };
            var mockResponse = new getSettledBatchListResponse
            {
                refId        = "1234",
                sessionToken = "sessiontoken",
                batchList    = batchDetailsType,
            };

            var errorResponse = new ANetApiResponse();
            var results       = new List <String>();
            const messageTypeEnum messageTypeOk = messageTypeEnum.Ok;

            SetMockControllerExpectations <getSettledBatchListRequest, getSettledBatchListResponse, getSettledBatchListController>(
                mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk);
            mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM);
            //mockController.MockObject.Execute();
            // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM);
            var controllerResponse = mockController.MockObject.GetApiResponse();

            Assert.IsNotNull(controllerResponse);

            Assert.IsNotNull(controllerResponse.batchList);
            LogHelper.info(Logger, "getSettledBatchList: Details:{0}", controllerResponse.batchList);
        }