public void MockARBGetSubscriptionListTest() { //define all mocked objects as final var mockController = GetMockController<ARBGetSubscriptionListRequest, ARBGetSubscriptionListResponse>(); var mockRequest = new ARBGetSubscriptionListRequest { merchantAuthentication = new merchantAuthenticationType {name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey}, refId = RefId, searchType = ARBGetSubscriptionListSearchTypeEnum.subscriptionActive, paging = new Paging { limit = 100, offset = 1 }, sorting = new ARBGetSubscriptionListSorting { orderBy = ARBGetSubscriptionListOrderFieldEnum.id, orderDescending = false }, }; var subscriptionDetail = new SubscriptionDetail { id = 1234, accountNumber = "1234", amount = SetValidTransactionAmount(Counter) / 100, }; var subscriptionDetails = new List<SubscriptionDetail> { subscriptionDetail }; var mockResponse = new ARBGetSubscriptionListResponse { refId = "1234", sessionToken = "sessiontoken", subscriptionDetails = subscriptionDetails.ToArray(), totalNumInResultSet = subscriptionDetails.Count, }; var errorResponse = new ANetApiResponse(); var results = new List<String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations<ARBGetSubscriptionListRequest, ARBGetSubscriptionListResponse, ARBGetSubscriptionListController>( 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.subscriptionDetails); LogHelper.info(Logger, "ARBGetSubscriptionList: Count:{0}, Details:{1}", controllerResponse.totalNumInResultSet, controllerResponse.subscriptionDetails); }
public static void ARBGetSubscriptionListResponse(ARBGetSubscriptionListResponse argument) { if (null != argument) { if (0 <= argument.totalNumInResultSet) { argument.totalNumInResultSetSpecified = true; } if (null != argument.subscriptionDetails) { foreach (var value in argument.subscriptionDetails) { SubscriptionDetail(value); } } } }