/////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a batch upload test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseBatchDelete()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchDelete");

            FeedQuery query   = new FeedQuery();
            Service   service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);

                Tracing.TraceMsg("Queried");

                // this should have a batch URI
                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI");


                AtomFeed batchFeed = new AtomFeed(new Uri(this.gBaseURI), service);

                // set the default operation.
                batchFeed.BatchData      = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.delete;

                Tracing.TraceMsg("Pouet ?");

                int i = 1;
                foreach (AtomEntry entry in baseFeed.Entries)
                {
                    AtomEntry batchEntry = new AtomEntry();
                    batchEntry.Id = entry.Id;

                    batchEntry.BatchData      = new GDataBatchEntryData();
                    batchEntry.BatchData.Id   = i.ToString();
                    batchEntry.BatchData.Type = GDataBatchOperationType.delete;

                    batchFeed.Entries.Add(batchEntry);
                    i++;
                }
                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));
                foreach (AtomEntry resultEntry in resultFeed.Entries)
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    Assert.IsTrue(data.Status.Code == 200, "Status code should be 200, is:" + data.Status.Code);
                }
            }
        }
        public void GoogleBaseBatchInsert()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchUpload");

            FeedQuery query   = new FeedQuery();
            Service   service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;



                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);

                // this should have a batch URI

                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI");

                AtomFeed batchFeed = new AtomFeed(new Uri(this.gBaseURI), service);

                // set the default operation. Unneeded, as the default is insert,
                // but want to make sure the code is complete
                batchFeed.BatchData      = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.delete;



                for (int i = 0; i < 20; i++)
                {
                    AtomEntry entry = ObjectModelHelper.CreateGoogleBaseEntry(i);
                    entry.BatchData = new GDataBatchEntryData();

                    entry.BatchData.Type = GDataBatchOperationType.insert;
                    entry.BatchData.Id   = i.ToString();

                    batchFeed.Entries.Add(entry);
                }

                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));

                foreach (AtomEntry resultEntry in resultFeed.Entries)
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    Assert.IsTrue(data.Status.Code == 201, "Status code should be 201, is:" + data.Status.Code);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a batch upload test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseBatchUpdateSameFeed()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchUpdateSameFeed");

            FeedQuery query   = new FeedQuery();
            Service   service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);
                // this should have a batch URI
                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI");

                int i = 0;

                foreach (AtomEntry entry in baseFeed.Entries)
                {
                    entry.BatchData      = new GDataBatchEntryData();
                    entry.BatchData.Id   = i.ToString();
                    entry.BatchData.Type = GDataBatchOperationType.update;
                    entry.Title.Text     = "Updated";
                    i++;
                }



                AtomFeed resultFeed = service.Batch(baseFeed, new Uri(baseFeed.Batch));

                foreach (AtomEntry resultEntry in resultFeed.Entries)
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    Assert.IsTrue(data.Status.Code == 200, "Status code should be 200, is:" + data.Status.Code);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a batch upload test</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseBatchMix()
        {
            Tracing.TraceMsg("Entering GoogleBaseBatchMix");

            FeedQuery query   = new FeedQuery();
            Service   service = new GBaseService(this.ApplicationName, this.gBaseKey);


            if (this.gBaseURI != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(this.gBaseURI);
                AtomFeed baseFeed = service.Query(query);
                // this should have a batch URI
                Assert.IsTrue(baseFeed.Batch != null, "This is a base Feed, it should have batch URI");

                AtomFeed batchFeed = new AtomFeed(baseFeed);

                // set the default operation.
                batchFeed.BatchData      = new GDataBatchFeedData();
                batchFeed.BatchData.Type = GDataBatchOperationType.insert;

                int  id      = 1;
                bool fUpdate = true;
                foreach (AtomEntry entry in baseFeed.Entries)
                {
                    AtomEntry batchEntry = batchFeed.Entries.CopyOrMove(entry);

                    if (fUpdate == true)
                    {
                        batchEntry.BatchData      = new GDataBatchEntryData();
                        batchEntry.BatchData.Id   = id.ToString();
                        batchEntry.BatchData.Type = GDataBatchOperationType.update;
                        batchEntry.Title.Text     = "Updated";
                        fUpdate = false;
                    }
                    else
                    {
                        batchEntry.BatchData      = new GDataBatchEntryData();
                        batchEntry.BatchData.Id   = id.ToString();
                        batchEntry.BatchData.Type = GDataBatchOperationType.delete;
                        fUpdate = true;
                    }


                    // insert one
                    id++;
                    batchEntry                = ObjectModelHelper.CreateGoogleBaseEntry(1);
                    batchEntry.BatchData      = new GDataBatchEntryData();
                    batchEntry.BatchData.Type = GDataBatchOperationType.insert;
                    batchEntry.BatchData.Id   = id.ToString();
                    batchFeed.Entries.Add(batchEntry);
                    id++;
                }



                AtomFeed resultFeed = service.Batch(batchFeed, new Uri(baseFeed.Batch));

                foreach (AtomEntry resultEntry in resultFeed.Entries)
                {
                    GDataBatchEntryData data = resultEntry.BatchData;
                    int testcode             = 200;
                    if (data.Type == GDataBatchOperationType.insert)
                    {
                        testcode = 201;
                    }
                    Assert.IsTrue(data.Status.Code == testcode, "Status code should be: " + testcode + ", is:" + data.Status.Code);
                }
            }
        }