示例#1
0
        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=""0"" 
                            retransmit=""n"">
                    <RequestCode>SV_ACCEPT_COUPON</RequestCode>
                    <TraceID>190826145135N000000</TraceID>
                    <Amount>0.00</Amount>
                    <SVAN>123</SVAN>
                    <ResponseCode hostCode=""93"">D</ResponseCode>
                    <DisplayMessage>Coupon (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-26T14:51:35")))
            {
                var e = await Assert.ThrowsAsync <OracleHospitalityClientException>(() =>
                                                                                    sut.CouponAcceptAsync(new AccountNumber("123"), new CouponCode("NotExist")));

                Assert.Equal("93", e.Code);
                Assert.Equal("Coupon (NotExist) cannot be found", e.Message);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        public async Task valid_coupon_code()
        {
            // For SV_ACCEPT_COUPON response, SVAN changes meaning from
            // mirroring the request SVAN to holding the issued CouponCode.
            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_ACCEPT_COUPON</RequestCode>
                    <TraceID>190826145135N000000</TraceID>
                    <Amount>0.00</Amount>
                    <SVAN>1005016</SVAN>
                    <ItemType>D</ItemType>
                    <ItemNumber>150</ItemNumber>
                    <ResponseCode>A</ResponseCode>
                    <DisplayMessage>10 DKK Coupon accepted</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.CouponAcceptAsync(new AccountNumber("doesNotMatter"), new CouponCode("1005016"));

                Assert.Equal(ItemType.Kind.Discount, actual.ItemType.Value);
                Assert.Equal(150, actual.ItemNumber.Value);
                Assert.Equal("10 DKK Coupon accepted", actual.DisplayMessage.Value);
                Assert.Equal("1005016", actual.AccountNumber.Value);
            }
        }