public void MockcreateCustomerShippingAddressTest() { //define all mocked objects as final var mockController = GetMockController <createCustomerShippingAddressRequest, createCustomerShippingAddressResponse>(); var mockRequest = new createCustomerShippingAddressRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, }; var mockResponse = new createCustomerShippingAddressResponse { refId = "1234", sessionToken = "sessiontoken", customerAddressId = "1234", }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createCustomerShippingAddressRequest, createCustomerShippingAddressResponse, createCustomerShippingAddressController>( 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.customerAddressId); LogHelper.info(Logger, "createCustomerShippingAddress: Details:{0}", controllerResponse.customerAddressId); }
public static void Run(string apiLoginId, string apiTransactionKey) { Console.WriteLine("CreateCustomerShippingAddress Sample"); ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { name = apiLoginId, ItemElementName = ItemChoiceType.transactionKey, Item = apiTransactionKey, }; customerAddressType officeAddress = new customerAddressType(); officeAddress.firstName = "Chris"; officeAddress.lastName = "brown"; officeAddress.address = "1200 148th AVE NE"; officeAddress.city = "NorthBend"; officeAddress.zip = "92101"; var request = new createCustomerShippingAddressRequest { customerProfileId = "10000", address = officeAddress, }; //Prepare Request var controller = new createCustomerShippingAddressController(request); controller.Execute(); //Send Request to EndPoint createCustomerShippingAddressResponse response = controller.GetApiResponse(); if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { if (response.messages.message != null) { Console.WriteLine("Success, customerAddressId : " + response.customerAddressId); } } else { if (response != null) { Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text); } } }