示例#1
0
        public void BatchIncludeTest()
        {
            ServiceContext context = Initializer.InitializeQBOServiceContextUsingoAuth();

            DataService.DataService service = new DataService.DataService(context);

            DataService.Batch batch       = service.CreateNewBatch();
            List <String>     optionsData = new List <string>();

            optionsData.Add("firsttxndate");

            batch.Add("Select * From CompanyInfo", "QueryCo", optionsData);
            batch.Execute();

            bool receivedIncludeParameter            = false;
            IntuitBatchResponse queryCompanyResponse = batch["QueryCo"];

            if (queryCompanyResponse.ResponseType == ResponseType.Query)
            {
                CompanyInfo companyInfo = queryCompanyResponse.Entities[0] as CompanyInfo;
                foreach (NameValue nameValue in companyInfo.NameValue)
                {
                    receivedIncludeParameter = nameValue.Name == "firsttxndate";
                    if (receivedIncludeParameter)
                    {
                        break;
                    }
                }
            }
            if (!receivedIncludeParameter)
            {
                Assert.Fail("CompanyInfo not returned");
            }
        }
示例#2
0
        internal static ReadOnlyCollection <IntuitBatchResponse> BatchTest <T>(ServiceContext context, Dictionary <OperationEnum, object> operationDictionary) where T : IEntity
        {
            DataService.DataService service = new DataService.DataService(context);
            List <T> addedList = new List <T>();
            List <T> newList   = new List <T>();


            QueryService <T> entityContext = new QueryService <T>(context);

            DataService.Batch batch = service.CreateNewBatch();

            foreach (KeyValuePair <OperationEnum, object> entry in operationDictionary)
            {
                if (entry.Value.GetType().Name.Equals(typeof(T).Name))
                {
                    batch.Add(entry.Value as IEntity, entry.Key.ToString() + entry.Value.GetType().Name, entry.Key);
                }
                else
                {
                    batch.Add(entry.Value as string, "Query" + typeof(T).Name);
                }
            }


            batch.Execute();

            return(batch.IntuitBatchItemResponses);
        }
示例#3
0
        public void BatchEntityTest()
        {
            ServiceContext context = Initializer.InitializeQBOServiceContextUsingoAuth();

            DataService.DataService service = new DataService.DataService(context);

            Customer customer      = CreateCustomer();
            Customer addedCustomer = service.Add(customer);

            Invoice invoice = QBOHelper.CreateInvoice(context);

            QueryService <Term> termContext = new QueryService <Term>(context);

            QueryService <TaxRate> taxRateContext = new QueryService <TaxRate>(context);
            QueryService <TaxCode> taxCodeContext = new QueryService <TaxCode>(context);
            QueryService <Item>    itemContext    = new QueryService <Item>(context);

            DataService.Batch batch = service.CreateNewBatch();
            batch.Add(addedCustomer, "UpdateCustomer", OperationEnum.update);
            batch.Add(invoice, "AddInvoice", OperationEnum.create);
            batch.Add(termContext.Take(5).ToIdsQuery(), "QueryTerm");
            batch.Add(taxRateContext.Take(5).ToIdsQuery(), "QueryTaxRate");
            batch.Add(taxCodeContext.Take(5).ToIdsQuery(), "QueryTaxCode");
            batch.Add(itemContext.Take(5).ToIdsQuery(), "QueryItem");

            batch.Execute();
            foreach (IntuitBatchResponse resp in batch.IntuitBatchItemResponses)
            {
                if (resp.ResponseType == ResponseType.Exception)
                {
                    Assert.Fail(resp.Exception.ToString());
                }
            }
        }
示例#4
0
        public void PreferencesBatchUsingoAuth()
        {
            DataService.DataService service = new DataService.DataService(qboContextoAuth);
            Preferences             found   = Helper.FindOrAdd <Preferences>(qboContextoAuth, new Preferences());

            DataService.Batch batch = service.CreateNewBatch();
            batch.Add(QBOHelper.UpdatePreferences(qboContextoAuth, found), "Update", OperationEnum.update);

            batch.Execute();

            ReadOnlyCollection <IntuitBatchResponse> batchResponses = batch.IntuitBatchItemResponses;

            int position = 0;

            foreach (IntuitBatchResponse resp in batchResponses)
            {
                if (resp.ResponseType == ResponseType.Exception)
                {
                    Assert.Fail(resp.Exception.ToString());
                }

                Assert.IsFalse(string.IsNullOrEmpty((resp.Entity as Preferences).Id));
                position++;
            }
        }
示例#5
0
        public void BatchInvoiceTest()
        {
            ServiceContext context = Initializer.InitializeQBOServiceContextUsingoAuth();

            DataService.DataService service          = new DataService.DataService(context);
            List <Invoice>          addedInvoiceList = new List <Invoice>();
            List <Invoice>          newInvoiceList   = new List <Invoice>();

            for (int i = 0; i < 5; i++)
            {
                Invoice invoice = QBOHelper.CreateInvoice(context);
                addedInvoiceList.Add(service.Add <Invoice>(invoice));
            }

            for (int i = 0; i < 5; i++)
            {
                newInvoiceList.Add(QBOHelper.CreateInvoice(context));
            }

            QueryService <Invoice> invoiceContext = new QueryService <Invoice>(context);

            DataService.Batch batch = service.CreateNewBatch();

            int count = 1;

            foreach (Invoice invoice in newInvoiceList)
            {
                batch.Add(invoice, "AddInvoice" + count, OperationEnum.create);
                count++;
            }

            count = 0;

            List <string> docNumbers = new List <string>();

            foreach (Invoice invoice in addedInvoiceList)
            {
                invoice.DocNumber = "SUDoc" + Guid.NewGuid().ToString().Substring(0, 6);
                docNumbers.Add(invoice.DocNumber);
                invoice.sparse          = true;
                invoice.sparseSpecified = true;
                invoice.TxnTaxDetail    = null;
                batch.Add(invoice, "UpdateInvoice" + count, OperationEnum.update);
                count++;
            }

            string[] values = docNumbers.ToArray();
            batch.Add(invoiceContext.Where(c => c.DocNumber.In(values)).ToIdsQuery(), "QueryInvoice1");
            batch.Execute();

            int position = 0;

            foreach (IntuitBatchResponse resp in batch.IntuitBatchItemResponses)
            {
                if (resp.ResponseType == ResponseType.Exception)
                {
                    Assert.Fail(resp.Exception.ToString());
                }

                if (position <= 4)
                {
                    Assert.IsFalse(string.IsNullOrEmpty((resp.Entity as Invoice).Id));
                }

                if (position > 4 && position < 10)
                {
                    Assert.IsTrue(((Invoice)resp.Entity).DocNumber.Contains("SUDoc"));
                }

                if (position == 10)
                {
                    Assert.IsTrue(resp.Entities.Count == 5);
                }

                position++;
            }
        }