private async Task <PostAccountTransactionResponse> FlipAccountState(CrmClient client, GetCustomerResponse customer, GetProgramResponse program) { var accountNumber = (string)customer.Rows[0].Columns["PRIMARYPOSREF"]; var accountState = (bool)customer.Rows[0].Columns["ACTIVE"]; var programCode = (string)program.Rows[0].Columns["PROGRAMCODE"]; var kind = accountState ? Type.Kind.CloseAccount : Type.Kind.ReopenAccount; var transaction = new CloseReopenTransactionBuilder() .WithType(kind) .WithCustomerFriendlyDescription("Updated by test") .WithProgramCode(programCode) .WithAccountPosRef(accountNumber); return(await client.PostAccountTransactionAsync(transaction)); }
public async Task reopen_account_already_open_disallowed() { const string response = @" <CRMMessage hostVersion=""9.1.0000.2301"" language=""en_US"" currency=""DKK"" isTrustedSAT=""false""> <RequestCode>PostAccountTransaction</RequestCode> <TraceID>Ark70tecHQrIBCXrS81XW</TraceID> <SVAN>2200005</SVAN> <ResponseCode>D</ResponseCode> <DisplayMessage>This account cannot be used, its status is invalid</DisplayMessage> </CRMMessage>"; var handler = CreateMockMessageHandler(HttpStatusCode.OK, CreateSoapResponse(response.Trim())); var executor = new OracleHospitalityExecutor(_options, _executorLogger, new HttpClient(handler)); var sut = new CrmClient(_options, executor); var e = await Assert.ThrowsAsync <OracleHospitalityClientException>( () => sut.PostAccountTransactionAsync(_transaction)); Assert.Equal("This account cannot be used, its status is invalid", e.Message); }
public async Task reopen_closed_account_allowed() { const string response = @" <CRMMessage hostVersion=""9.1.0000.2301"" language=""en_US"" currency=""DKK"" isTrustedSAT=""false""> <RequestCode>PostAccountTransaction</RequestCode> <TraceID>Ark70tecHQrIBCXrS81XW</TraceID> <SVAN>2200005</SVAN> <ResponseCode>A</ResponseCode> <AccountBalance>0.00</AccountBalance> <LocalBalance>0.00</LocalBalance> <DisplayMessage>Account 2200005 has been re-opened</DisplayMessage> </CRMMessage>"; var handler = CreateMockMessageHandler(HttpStatusCode.OK, CreateSoapResponse(response.Trim())); var executor = new OracleHospitalityExecutor(_options, _executorLogger, new HttpClient(handler)); var sut = new CrmClient(_options, executor); var actual = await sut.PostAccountTransactionAsync(_transaction); Assert.Equal("Account 2200005 has been re-opened", actual.DisplayMessage.Value); }