public void PP_01_Mock_Success() { XmlNode settings = GetNode("TestMessages/MessageGroup[@name='PrepaidVoucher']/Message[@name='PP_01_ConsumeVoucher']/MessageContent/CustomContent/Settings"); int customerID = Int32.Parse(XmlUtilities.SafeSelectText(settings, "CustomerId")); int financialAccountId = Int32.Parse(XmlUtilities.SafeSelectText(settings, "FinancialAccountId")); long voucherTicketNumber = long.Parse(XmlUtilities.SafeSelectText(settings, "VoucherTicketNumber")); string asmUsername = XmlUtilities.SafeSelectText(settings, "ASMUsername"); string asmPassword = XmlUtilities.SafeSelectText(settings, "ASMPassword"); string asmDsn = XmlUtilities.SafeSelectText(settings, "ASMDsn"); PrepaidVoucherService.PrepaidVoucher voucher = new PrepaidVoucherService.PrepaidVoucher(); voucher.FinancialAccountId = financialAccountId; voucher.CustomerId = customerID; voucher.VoucherTicketNumber = voucherTicketNumber; PrepaidVoucherService.AuthenticationHeader header = new PrepaidVoucherService.AuthenticationHeader(); header.Password = asmPassword; header.Username = asmUsername; header.Dsn = asmDsn; PrepaidVoucherService.PrepaidVoucherRequest request = new PrepaidVoucherService.PrepaidVoucherRequest(voucher, header); PrepaidVoucherServiceMock service = new PrepaidVoucherServiceMock(_context); PrepaidVoucherService.PrepaidVoucherResponse response = service.ConsumeVoucher(request); service.VerifyExpectations(); Console.WriteLine("Return code: {0}; Voucher Amount: {1}; FT ID: {2}", response.returnCode, response.prepaidVoucher.VoucherAmount, response.financialTransactionId); Assert.AreEqual(ReturnCode.VmsValidationSuccessful, response.returnCode, "Return code was not successful from web service call."); }
public void PP_01_Mock_Auth_Failure() { PrepaidVoucherService.PrepaidVoucher voucher = new PrepaidVoucherService.PrepaidVoucher(); voucher.FinancialAccountId = 123; voucher.CustomerId = 456; voucher.VoucherTicketNumber = 123456; PrepaidVoucherService.PrepaidVoucherRequest request = new PrepaidVoucherService.PrepaidVoucherRequest(voucher, null); PrepaidVoucherService service = new PrepaidVoucherService(_context); PrepaidVoucherService.PrepaidVoucherResponse response = service.ConsumeVoucher(request); Console.WriteLine("Return code: {0}", response.returnCode.ToString()); Assert.AreEqual(ReturnCode.IbsCiUnauthorized, response.returnCode, "Return code was not unauthorized from web service call."); }
public void PP_01_Mock_Exception() { PrepaidVoucherService.PrepaidVoucher voucher = new PrepaidVoucherService.PrepaidVoucher(); voucher.FinancialAccountId = 123; voucher.CustomerId = 456; voucher.VoucherTicketNumber = 123456; PrepaidVoucherService.AuthenticationHeader header = new PrepaidVoucherService.AuthenticationHeader(); header.Password = "******"; header.Username = "******"; header.Dsn = "UnitTest"; PrepaidVoucherService.PrepaidVoucherRequest request = new PrepaidVoucherService.PrepaidVoucherRequest(voucher, header); PrepaidVoucherServiceExceptionMock service = new PrepaidVoucherServiceExceptionMock(_context); service.exceptionText = "A custom error occurred. This is the error text."; PrepaidVoucherService.PrepaidVoucherResponse response = service.ConsumeVoucher(request); Assert.AreEqual(ReturnCode.IbsCiSystemError, response.returnCode, "Exception did not return expected error code."); }