public async Task end_to_end() { // To create a new account, specify a non-existing account number. // Creating an account isn't part of this test because (1) accounts // can never be deleted and (2) we'd have to determine next // available account number prior to creating the account. var accountNumber = new AccountNumber("2200000"); var client = new PosClient(_messageSequencingStrategy, _executor); var pointIssue = await client.PointIssueAsync(accountNumber); var couponInquiry = await client.CouponInquiryAsync(pointIssue.AccountNumber); var couponCode = new CouponCode("10DKK"); var couponIssue = await client.CouponIssueAsync(accountNumber, couponCode); var couponAccept = await client.CouponAcceptAsync(accountNumber, couponIssue.CouponCode); }
public async Task valid_coupon_code() { const string response = @" <SVCMessage hostVersion=""9.1.0000.2301"" version=""1"" posIntfcName=""posInterfaceName"" posIntfcVersion=""1.00"" language=""en-US"" currency=""DKK"" sequence=""00"" retransmit=""n""> <RequestCode>SV_ISSUE_COUPON</RequestCode> <TraceID>190826145135N000000</TraceID> <Amount>0.00</Amount> <SVAN>123</SVAN> <AccountCurrency>DKK</AccountCurrency> <ExchangeRate>1.00</ExchangeRate> <ItemType>T</ItemType> <ItemNumber>1</ItemNumber> <PrintLines /> <CouponCode>1006022</CouponCode> <ResponseCode>A</ResponseCode> <DisplayMessage>Coupon (10 DKK) has been issued to this account.</DisplayMessage> </SVCMessage>"; var handler = CreateMockMessageHandler(HttpStatusCode.OK, CreateSoapResponse(response.Trim())); var executor = new OracleHospitalityExecutor(_options, _executorLogger, new HttpClient(handler)); var sut = new PosClient(_messageSequencingStrategy, executor); using (new TimeProviderTestScope(() => DateTime.Parse("2019-08-26T14:51:35"))) { var actual = await sut.CouponIssueAsync(new AccountNumber("123"), new CouponCode("doesNotMatter")); Assert.Equal("1006022", actual.CouponCode.Value); Assert.Equal("Coupon (10 DKK) has been issued to this account.", actual.DisplayMessage.Value); Assert.Equal(ItemType.Kind.Tender, actual.ItemType.Value); Assert.Equal(1, actual.ItemNumber.Value); Assert.Empty(actual.PrintLines.Values); Assert.Equal(Currency.Kind.DKK, actual.AccountCurrency.Value); Assert.Equal(1.00m, actual.ExchangeRate.Value); } }
public async Task invalid_coupon_code() { const string response = @" <SVCMessage hostVersion=""9.1.0000.2301"" version=""1"" posIntfcName=""posInterfaceName"" posIntfcVersion=""1.00"" language=""en-US"" currency=""DKK"" sequence=""00"" retransmit=""n""> <RequestCode>SV_ISSUE_COUPON</RequestCode> <TraceID>190827125052N000000</TraceID> <Amount>0.00</Amount> <SVAN>123</SVAN> <AccountCurrency>DKK</AccountCurrency> <ExchangeRate>1.00</ExchangeRate> <ItemType>T</ItemType> <ItemNumber>1</ItemNumber> <ResponseCode hostCode=""127"">D</ResponseCode> <DisplayMessage>Coupon code (NotExist) cannot be found.</DisplayMessage> </SVCMessage>"; var handler = CreateMockMessageHandler(HttpStatusCode.OK, CreateSoapResponse(response.Trim())); var executor = new OracleHospitalityExecutor(_options, _executorLogger, new HttpClient(handler)); var sut = new PosClient(_messageSequencingStrategy, executor); using (new TimeProviderTestScope(() => DateTime.Parse("2019-08-27T12:50:52"))) { var e = await Assert.ThrowsAsync <OracleHospitalityClientException>( () => sut.CouponIssueAsync(new AccountNumber("123"), new CouponCode("NotExist"))); Assert.Equal("127", e.Code); Assert.Equal("Coupon code (NotExist) cannot be found.", e.Message); } }