public void BasicDataExtDefDelResponseTest()
        {
            var ret = "<DataExtDefDelRet><OwnerID>{7d543f23-f3b1-4dea-8ff4-37bd26d15e6c}</OwnerID><DataExtName>name</DataExtName></DataExtDefDelRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<DataExtDefDelRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "DataExtDefDelRs"));
            var dataExtDef = rs.DataExtDefDelRet;

            Assert.AreEqual("name", dataExtDef.DataExtName);
        }
        public void BasicInvoiceAddResponseTest()
        {
            var invoiceRet = "<InvoiceRet><TxnID>80000001-1422671082</TxnID><TimeCreated>2015-01-30T18:24:42-08:00</TimeCreated><TimeModified>2015-01-30T18:24:42-08:00</TimeModified><EditSequence>1422671082</EditSequence><CustomerRef><ListID>123456</ListID></CustomerRef><TxnDate>2015-02-19</TxnDate></InvoiceRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<InvoiceAddRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(invoiceRet, "InvoiceAddRs"));
            var invoice = rs.InvoiceRet;

            Assert.AreEqual("80000001-1422671082", invoice.TxnID);
            Assert.AreEqual("123456", invoice.CustomerRef.ListID);
        }
        public void PreferredDeliveryMethod_Mail_ShouldBeValid()
        {
            var ret = "<CustomerRet><ListID>80000001-1422671082</ListID><TimeCreated>2015-04-03T10:06:17-08:00</TimeCreated><TimeModified>2015-04-03T10:06:17-08:00</TimeModified><EditSequence>1422671082</EditSequence><Name>Jean-S&#233;bastien Goupil</Name><FullName>Jean-S&#233;bastien Goupil</FullName><IsActive>true</IsActive><PreferredDeliveryMethod>Mail</PreferredDeliveryMethod></CustomerRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<CustomerQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "CustomerQueryRs"));
            var customers = rs.CustomerRet;
            var customer = customers[0];

            Assert.AreEqual(1, customers.Length);
            Assert.AreEqual(PreferredDeliveryMethod.Mail, customer.PreferredDeliveryMethod);
        }
        public void BasicCustomerResponseTest_WithEnum()
        {
            var ret = "<CustomerRet><JobStatus>InProgress</JobStatus></CustomerRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<CustomerQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "CustomerQueryRs"));
            var customers = rs.CustomerRet;
            var customer = customers[0];

            Assert.AreEqual(1, customers.Length);
            Assert.AreEqual(JobStatus.InProgress, customer.JobStatus);
        }
        public void BasicEntityQueryResponseTest()
        {
            var ret = "<EmployeeRet><Name>SomeName</Name></EmployeeRet><EmployeeRet><Name>Other</Name></EmployeeRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<EntityQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "EntityQueryRs"));
            var employees = rs.EmployeeRet;

            Assert.AreEqual(2, employees.Count());
            Assert.AreEqual("SomeName", employees.First().Name);
            Assert.AreEqual("Other", employees.Last().Name);
        }
        public void BasicDataDelExtResponseTest()
        {
            var ret = "<DataExtDelRet><OwnerID>{7d543f23-f3b1-4dea-8ff4-37bd26d15e6c}</OwnerID><DataExtName>name</DataExtName><TxnDataExtType>CreditCardCredit</TxnDataExtType><TxnID>1234</TxnID><TimeDeleted>2015-02-10T00:00:00</TimeDeleted></DataExtDelRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<DataExtDelRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "DataExtDelRs"));
            var dataExt = rs.DataExtDelRet;

            Assert.AreEqual("name", dataExt.DataExtName);
            Assert.AreEqual(TxnDataExtType.CreditCardCredit, dataExt.TxnDataExtType.Value);
            Assert.AreEqual("1234", dataExt.TxnID);
            Assert.AreEqual(new DATETIMETYPE(DateTime.Parse("2015-02-10")), dataExt.TimeDeleted);
        }
        public void BasicCustomerResponseTest()
        {
            var ret = "<CustomerRet><ListID>80000001-1422671082</ListID><TimeCreated>2015-01-30T18:24:42-08:00</TimeCreated><TimeModified>2015-01-30T18:24:42-08:00</TimeModified><EditSequence>1422671082</EditSequence><Name>Jean-S&#233;bastien Goupil</Name><FullName>Jean-S&#233;bastien Goupil</FullName><IsActive>true</IsActive></CustomerRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<CustomerQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "CustomerQueryRs"));
            var customers = rs.CustomerRet;
            var customer = customers[0];

            Assert.AreEqual(1, customers.Length);
            Assert.AreEqual("80000001-1422671082", customer.ListID);
            Assert.AreEqual("Jean-Sébastien Goupil", customer.Name);
        }
        public void BasicDataExtDefModResponseTest()
        {
            var ret = "<DataExtDefRet><OwnerID>{7d543f23-f3b1-4dea-8ff4-37bd26d15e6c}</OwnerID><DataExtID>123</DataExtID><DataExtName>name</DataExtName><DataExtType>STR255TYPE</DataExtType><AssignToObject>Account</AssignToObject><AssignToObject>Charge</AssignToObject></DataExtDefRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<DataExtDefModRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "DataExtDefModRs"));
            var dataExtDef = rs.DataExtDefRet;

            Assert.AreEqual("name", dataExtDef.DataExtName);
            Assert.AreEqual(DataExtType.STR255TYPE, dataExtDef.DataExtType);
            Assert.AreEqual(2, dataExtDef.AssignToObject.Count());
            Assert.AreEqual(AssignToObject.Account, dataExtDef.AssignToObject.First());
            Assert.AreEqual(AssignToObject.Charge, dataExtDef.AssignToObject.Last());
        }
        public void BasicCustomerResponseTest_WithObject()
        {
            var ret = "<CustomerRet><ShipAddress><City>Seattle</City><State>WA</State></ShipAddress></CustomerRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<CustomerQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "CustomerQueryRs"));
            var customers = rs.CustomerRet;
            var customer = customers[0];

            Assert.AreEqual(1, customers.Length);
            Assert.IsNotNull(customer.ShipAddress);
            Assert.AreEqual("Seattle", customer.ShipAddress.City);
            Assert.AreEqual("WA", customer.ShipAddress.State);
        }
        public void BasicCustomerResponseTest_WithIEnumerable()
        {
            var ret = "<CustomerRet><AdditionalContactRef><ContactName>Name1</ContactName><ContactValue>Value1</ContactValue></AdditionalContactRef><AdditionalContactRef><ContactName>Name2</ContactName><ContactValue>Value2</ContactValue></AdditionalContactRef></CustomerRet>";

            var response = new QbXmlResponse();
            var rs = response.GetSingleItemFromResponse<CustomerQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "CustomerQueryRs"));
            var customers = rs.CustomerRet;
            var customer = customers[0];

            Assert.AreEqual(1, customers.Length);
            Assert.AreEqual(2, customer.AdditionalContactRef.Count());
            Assert.AreEqual("Name1", customer.AdditionalContactRef.First().ContactName);
            Assert.AreEqual("Value1", customer.AdditionalContactRef.First().ContactValue);
            Assert.AreEqual("Name2", customer.AdditionalContactRef.Last().ContactName);
            Assert.AreEqual("Value2", customer.AdditionalContactRef.Last().ContactValue);
        }
        public void TimeZoneBugFixTests()
        {
            var ret = "<CustomerRet><ListID>80000001-1422671082</ListID><TimeCreated>2015-04-03T10:06:17-08:00</TimeCreated><TimeModified>2015-04-03T10:06:17-08:00</TimeModified><EditSequence>1422671082</EditSequence><Name>Jean-S&#233;bastien Goupil</Name><FullName>Jean-S&#233;bastien Goupil</FullName><IsActive>true</IsActive></CustomerRet>";

            var response = new QbXmlResponse(new QbXmlResponseOptions
            {
                TimeZoneBugFix = QuickBooksTestHelper.GetPacificStandardTimeZoneInfo()
            });
            var rs = response.GetSingleItemFromResponse<CustomerQueryRsType>(QuickBooksTestHelper.CreateQbXmlWithEnvelope(ret, "CustomerQueryRs"));
            var customers = rs.CustomerRet;
            var customer = customers[0];

            Assert.AreEqual(17, customer.TimeModified.ToDateTime().ToUniversalTime().Hour);
        }