public void valid(string source, string name)
        {
            var rs = new RequestSource(XE.Parse(source));

            Assert.Equal(name, rs.Name_.Value);
            Assert.Equal(name, rs.Name_.ToString());
        }
        public void request_generation()
        {
            const string expected = @"
                <CRMMessage language=""en_US"" currency=""DKK"">
                  <RequestSource name=""acme.com"" version=""1"" />
                  <RequestCode>GetCustomer</RequestCode>
                  <QueryCriteria conditions=""primaryposref = ?"">
                    <Condition name=""primaryposref"" value=""123"" />
                  </QueryCriteria>
                  <ResultSetDefinition>
                    <Column>firstname</Column>
                    <Column>lastname</Column>
                  </ResultSetDefinition>
                </CRMMessage>";

            var request = new GetCustomerRequest(
                "acme.com",
                "primaryposref = ?",
                new[] { new ColumnValue("primaryposref", "123") },
                new[]
            {
                new Column("firstname"),
                new Column("lastname")
            });

            var requestXml = request.BuildRequestDocument();

            Assert.Equal(XE.Parse(expected).ToString(), requestXml.ToString());
        }
예제 #3
0
        public void expect_attribute_failure_when_attribute_missing()
        {
            var e  = XE.Parse(@"<e a=""123"" />");
            var ae = Assert.Throws <ArgumentException>(() => ExpectAttribute(e, "b"));

            Assert.Equal("Expected 'b' attribute", ae.Message);
        }
예제 #4
0
        public void request_generation()
        {
            const string expected = @"
                <CRMMessage language=""en_US"" currency=""DKK"">
                  <RequestSource name=""acme.com"" version=""1"" />
                  <RequestCode>PostAccountTransaction</RequestCode>
                  <Transaction>
                    <Type>6</Type>
                    <CustFriendlyDesc>Updated by test</CustFriendlyDesc>
                    <ProgramCode>EMPDISC</ProgramCode>
                    <AccountPOSRef>2200005</AccountPOSRef>
                    <TransDateTime>2019-10-08 11:11:01.8</TransDateTime>
                    <BusinessDate>2019-10-08</BusinessDate>
                    <CardPresent>0</CardPresent>
                    <LocalCurrencyISOCode>DKK</LocalCurrencyISOCode>
                    <TraceID>Ark70tecHQrIBCXrS81XW</TraceID>
                  </Transaction>
                </CRMMessage>";

            _transaction = _transaction
                           .WithTransactionDateTime(new DateTime(2019, 10, 8, 11, 11, 1, 800))
                           .WithBusinessDate(new DateTime(2019, 10, 08));

            var request    = new PostAccountTransactionRequest("acme.com", _transaction);
            var requestXml = request.BuildRequestDocument();

            Assert.Equal(XE.Parse(expected).ToString(), requestXml.ToString());
        }
예제 #5
0
        public void consume_attribute_fail_when_attribute_missing()
        {
            var e  = XE.Parse(@"<e a=""123"" />");
            var ae = Assert.Throws <ArgumentException>(() => ConsumeAttribute(e, "a2"));

            Assert.Equal("Expected 'a2' attribute", ae.Message);
        }
예제 #6
0
        public void consume_attribute_success_when_attribute_present()
        {
            var e = XE.Parse(@"<e a=""123"" />");

            ConsumeAttribute(e, "a");
            Assert.Null(e.Attribute("a"));
        }
예제 #7
0
        public void expect_attribute_success_when_attribute_present()
        {
            var e = XE.Parse(@"<e a=""123"" />");
            var a = ExpectAttribute(e, "a");

            Assert.Equal("123", a.Value);
        }
        public void invalid_actions()
        {
            var actions = XE.Parse("<Actions></Actions>");
            var e       = Assert.Throws <ArgumentException>(() => new Actions(actions));

            Assert.Contains("Expected at least one 'Action' element", e.Message);
        }
        public void approved_response(string response, ResponseCode.Kind kind, string code)
        {
            var k = new ResponseCode(XE.Parse(response));

            Assert.Equal(kind, k.Value);
            Assert.Equal(code, k.ToString());
        }
        public void update_existing_customer_request_generation()
        {
            const string expected = @"
                <CRMMessage language=""en_US"" currency=""DKK"">
                  <RequestSource name=""acme.com"" version=""1"" />
                  <RequestCode>SetCustomer</RequestCode>
                  <DataSet>
                    <DataSetColumns>
                      <DSColumn name=""firstname"" />
                      <DSColumn name=""lastname"" />
                    </DataSetColumns>
                    <Rows>
                      <Row id=""123"">
                        <Col>Rubber</Col>
                        <Col>Duck</Col>
                      </Row>
                    </Rows>
                  </DataSet>
                </CRMMessage>";

            var request = new SetCustomerRequest(
                "acme.com",
                123,
                new[]
            {
                new ColumnValue("firstname", "Rubber"),
                new ColumnValue("lastname", "Duck")
            });

            var requestXml = request.BuildRequestDocument();

            Assert.Equal(XE.Parse(expected).ToString(), requestXml.ToString());
        }
예제 #11
0
        public void empty_print_lines_response()
        {
            var element = XE.Parse("<PrintLines></PrintLines>");
            var r       = new PrintLines(element);

            Assert.Empty(r.Values);
        }
        public void data_center_initiated_error_response()
        {
            var r = new ResponseCode(XE.Parse(@"<ResponseCode hostCode=""20"">D</ResponseCode>"));

            Assert.Equal(ResponseCode.Kind.DataCenterInitiatedError, r.Value);
            Assert.Equal("20", r.HostCode);
        }
예제 #13
0
        public void map_attribute_fail_when_attribute_missing()
        {
            var e  = XE.Parse(@"<e a=""123"" />");
            XA  a  = null;
            var ae = Assert.Throws <ArgumentException>(() => MapAttribute(e, "a2", x => a = x));

            Assert.Equal("Expected 'a2' attribute", ae.Message);
        }
예제 #14
0
        public void map_element_fail_when_element_mssing()
        {
            var e  = XE.Parse("<e><e1>42</e1></e>");
            XE  el = null;
            var ae = Assert.Throws <ArgumentException>(() => MapElement(e, "e2", x => el = x));

            Assert.Equal("Expected 'e2' element", ae.Message);
        }
예제 #15
0
        public void map_element_success_when_element_present()
        {
            var e  = XE.Parse("<e><e1>42</e1></e>");
            XE  el = null;

            MapElement(e, "e1", x => el = x);
            Assert.Equal("42", el.Value);
        }
        public void valid()
        {
            const string element = @"<Error code=""1"">Unsupported parameter: NonExistingEntity</Error>";
            var          error   = new Error(XE.Parse(element));

            Assert.Equal("1", error.Code);
            Assert.Equal("Unsupported parameter: NonExistingEntity", error.Message);
        }
예제 #17
0
        public void map_attribute_success_when_attribute_present()
        {
            var e = XE.Parse(@"<e a=""123"" />");
            XA  a = null;

            MapAttribute(e, "a", x => a = x);
            Assert.Equal("123", a.Value);
        }
예제 #18
0
        public void consume_element_success_when_element_present()
        {
            var e = XE.Parse(@"
                <e>
                    <e1>42</e1>
                </e>");

            ConsumeElement(e, "e1");
            Assert.Equal("<e />", e.ToString());
        }
예제 #19
0
        public void expect_element_failure_when_element_missing()
        {
            var e  = XE.Parse(@"
                <e>
                    <e1>42</e1>
                </e>");
            var ae = Assert.Throws <ArgumentException>(() => ExpectElement(e, "e2"));

            Assert.Equal("Expected 'e2' element", ae.Message);
        }
예제 #20
0
        public void expect_element_success_when_element_present()
        {
            var e  = XE.Parse(@"
                <e>
                    <e1>42</e1>
                </e>");
            var e1 = ExpectElement(e, "e1");

            Assert.Equal("42", e1.Value);
        }
예제 #21
0
        public void expect_elements_fail_when_collection_missing()
        {
            var e  = XE.Parse(@"
                <e>
                    <e1>42</e1>
                </e>");
            var ae = Assert.Throws <ArgumentException>(() => ExpectElements(e, "e2"));

            Assert.Equal("Expected at least one 'e2' element", ae.Message);
        }
예제 #22
0
        public void expect_elements_success_when_collection_present()
        {
            var e   = XE.Parse(@"
                <e>
                    <e1>42</e1>
                    <e1>43</e1>
                </e>");
            var e1s = ExpectElements(e, "e1");

            Assert.Equal(2, e1s.Length);
            Assert.Equal("42", e1s[0].Value);
            Assert.Equal("43", e1s[1].Value);
        }
        public void request_generation()
        {
            const string expected = @"
                <CRMMessage language=""en_US"" currency=""DKK"">
                  <RequestSource name=""acme.com"" version=""1"" />
                  <RequestCode>GetColumnList</RequestCode>
                  <QueryCriteria request=""customer"" />
                </CRMMessage>";

            var request    = new GetColumnListRequest("acme.com", "customer");
            var requestXml = request.BuildRequestDocument();

            Assert.Equal(XE.Parse(expected).ToString(), requestXml.ToString());
        }
        public void valid()
        {
            const string element = @"
                <QueryCriteria conditions=""primaryposref = ?"">
                    <Condition name=""primaryposref"" value=""123"" />
                </QueryCriteria>";

            var criteria = new QueryCriteria(XE.Parse(element));

            Assert.Equal("primaryposref = ?", criteria.Conditions_.Value);
            Assert.Single(criteria.ConditionDetails);
            Assert.Equal("primaryposref", criteria.ConditionDetails[0].Name.Value);
            Assert.Equal("123", criteria.ConditionDetails[0].Value_.Value_);
        }
예제 #25
0
        public void multiple_print_lines_response()
        {
            var element = XE.Parse(@"
                <PrintLines>
                    <PrintLine>Foo</PrintLine>
                    <PrintLine>Bar</PrintLine>
                </PrintLines>");

            var r = new PrintLines(element);

            Assert.Equal(2, r.Values.Count);
            Assert.Equal("Foo", r.Values[0].Value);
            Assert.Equal("Bar", r.Values[1].Value);
        }
        public void valid()
        {
            const string element = @"
                <ResultSetDefinition>
                   <Column>firstname</Column>
                   <Column>lastname</Column>
                </ResultSetDefinition>";

            var d = new ResultSetDefinition(XE.Parse(element));

            Assert.Equal(2, d.Columns.Count);
            Assert.Equal("firstname", d.Columns[0].Value);
            Assert.Equal("lastname", d.Columns[1].Value);
        }
예제 #27
0
        public void validate_attribute_success_when_attribute_present()
        {
            var e1 = XE.Parse(@"<e a=""123"" />");
            var e2 = XE.Parse(@"<e a=""123"" />");

            var run = false;

            ValidateAttribute(e1, e2, "a", (a, b) =>
            {
                run = true;
                return(a == b);
            });

            Assert.True(run);
        }
예제 #28
0
        public void validate_element_success_when_element_present()
        {
            var e1 = XE.Parse("<e1><e2>123</e2></e1>");
            var e2 = XE.Parse("<e1><e2>123</e2></e1>");

            var run = false;

            ValidateElement(e1, e2, "e2", (a, b) =>
            {
                run = true;
                return(a == b);
            });

            Assert.True(run);
        }
예제 #29
0
        public void validate_attribute_fail_when_attribute_missing()
        {
            var e1 = XE.Parse(@"<e a=""123"" />");
            var e2 = XE.Parse(@"<e a=""1234"" />");

            var run = false;
            var e   = Assert.Throws <OracleHospitalityClientException>(() =>
                                                                       ValidateAttribute(e1, e2, "a", (a, b) =>
            {
                run = true;
                return(a == b);
            }));

            Assert.True(run);
            Assert.Equal("Expected attribute values for 'a' to be equal. Was '123' and '1234'", e.Message);
        }
예제 #30
0
        public void validate_element_fail_when_element_missing()
        {
            var e1 = XE.Parse("<e1><e2>123</e2></e1>");
            var e2 = XE.Parse("<e1><e2>1234</e2></e1>");

            var run = false;
            var e   = Assert.Throws <OracleHospitalityClientException>(() =>
                                                                       ValidateElement(e1, e2, "e2", (a, b) =>
            {
                run = true;
                return(a == b);
            }));

            Assert.True(run);
            Assert.Equal("Expected element values for 'e2' to be equal. Was '123' and '1234'", e.Message);
        }