Ejemplo n.º 1
0
 public void TypeTest()
 {
     GDataBatchEntryData target = new GDataBatchEntryData(); // TODO: Initialize to an appropriate value
     GDataBatchOperationType expected = GDataBatchOperationType.update;
     GDataBatchOperationType actual;
     target.Type = expected;
     actual = target.Type;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// parses the current position in the xml reader and fills
        /// the provided GDataEntryBatch property on the entry object
        /// </summary>
        /// <param name="reader">the xmlreader positioned at a batch element</param>
        /// <param name="entry">the atomentry object to fill in</param>
        protected void ParseBatch(XmlReader reader, AtomEntry entry)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (entry == null)
            {
                throw new ArgumentNullException("entry");
            }

            if (IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace))
            {
                object elementName = reader.LocalName;

                if (entry.BatchData == null)
                {
                    entry.BatchData = new GDataBatchEntryData();
                }

                GDataBatchEntryData batch = entry.BatchData;

                if (elementName.Equals(this.nameTable.BatchId))
                {
                    batch.Id = Utilities.DecodedValue(reader.ReadString());
                }
                else if (elementName.Equals(this.nameTable.BatchOperation))
                {
                    batch.Type = ParseOperationType(reader);
                }
                else if (elementName.Equals(this.nameTable.BatchStatus))
                {
                    batch.Status = GDataBatchStatus.ParseBatchStatus(reader, this);
                }
                else if (elementName.Equals(this.nameTable.BatchInterrupt))
                {
                    batch.Interrupt = GDataBatchInterrupt.ParseBatchInterrupt(reader, this);
                }
                else
                {
                    Tracing.TraceInfo("got an unknown batch element: " + elementName.ToString());
                    // default extension parsing
                    ParseExtensionElements(reader, entry);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        
        
        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test, inserts a new contact</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void ModelBatchContactsTest()
        {
            const int numberOfInserts = 5;
            Tracing.TraceMsg("Entering ModelInsertContactsTest");

            DeleteAllContacts();

            RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord);
            rs.AutoPaging = true; 

            ContactsRequest cr = new ContactsRequest(rs);

            List<Contact> list = new List<Contact>();

            Feed<Contact> f = cr.GetContacts();

            for (int i = 0; i < numberOfInserts; i++)
            {
                Contact entry = new Contact();
                entry.AtomEntry = ObjectModelHelper.CreateContactEntry(i);
                entry.PrimaryEmail.Address = "joe" + i.ToString() + "@doe.com";
                GDataBatchEntryData g = new GDataBatchEntryData();
                g.Id = i.ToString(); 
                g.Type = GDataBatchOperationType.insert;
                entry.BatchData = g;
                list.Add(entry);
            }

            Feed<Contact> r = cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.Default);
            list.Clear();

            int iVerify = 0;

            foreach (Contact c in r.Entries )
            {
                // let's count and update them
                iVerify++; 
                c.Title = "get a nother one"; 
                c.BatchData.Type = GDataBatchOperationType.update;
                list.Add(c);
            }
            Assert.IsTrue(iVerify == numberOfInserts, "should have gotten 5 inserts");

            Feed<Contact> u = cr.Batch(list, new Uri(r.AtomFeed.Batch), GDataBatchOperationType.Default);
            list.Clear();

            iVerify = 0; 
            foreach (Contact c in u.Entries )
            {
                // let's count and update them
                iVerify++; 
                c.BatchData.Type = GDataBatchOperationType.delete;
                list.Add(c);
            }
            Assert.IsTrue(iVerify == numberOfInserts, "should have gotten 5 updates");

            Feed<Contact> d = cr.Batch(list, new Uri(u.AtomFeed.Batch), GDataBatchOperationType.Default);

            iVerify = 0; 
            foreach (Contact c in d.Entries )
            {
                if (c.BatchData.Status.Code == 200)
                {
                    // let's count and update them
                    iVerify++; 
                }
            }
            Assert.IsTrue(iVerify == numberOfInserts, "should have gotten 5 deletes");

        }
Ejemplo n.º 4
0
 public void StatusTest()
 {
     GDataBatchEntryData target = new GDataBatchEntryData(); // TODO: Initialize to an appropriate value
     GDataBatchStatus expected = new GDataBatchStatus();
     GDataBatchStatus actual;
     target.Status = expected;
     actual = target.Status;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 5
0
 public void GDataBatchEntryDataConstructorTest()
 {
     string ID = "TestValue"; // TODO: Initialize to an appropriate value
     GDataBatchOperationType type = GDataBatchOperationType.update;
     GDataBatchEntryData target = new GDataBatchEntryData(ID, type);
     Assert.IsNotNull(target);
     Assert.AreEqual(type, target.Type);
     Assert.AreEqual(ID, target.Id);
 }
Ejemplo n.º 6
0
 public void GDataBatchEntryDataConstructorTest1()
 {
     GDataBatchOperationType type = GDataBatchOperationType.update;
     GDataBatchEntryData target = new GDataBatchEntryData(type);
     Assert.IsNotNull(target);
     Assert.AreEqual(type, target.Type);
 }
Ejemplo n.º 7
0
 public void GDataBatchEntryDataConstructorTest2()
 {
     GDataBatchEntryData target = new GDataBatchEntryData();
     Assert.IsNotNull(target);
     Assert.AreEqual(GDataBatchOperationType.Default, target.Type);
 }
Ejemplo n.º 8
0
 public void IdTest()
 {
     GDataBatchEntryData target = new GDataBatchEntryData(); // TODO: Initialize to an appropriate value
     string expected = "TestValue";            
     string actual;
     target.Id = expected;
     actual = target.Id;
     Assert.AreEqual(expected, actual);
 }
Ejemplo n.º 9
0
 public void InterruptTest()
 {
     GDataBatchEntryData target = new GDataBatchEntryData(); // TODO: Initialize to an appropriate value
     GDataBatchInterrupt expected = new GDataBatchInterrupt();
     GDataBatchInterrupt actual;
     target.Interrupt = expected;
     actual = target.Interrupt;
     Assert.AreEqual(expected, actual);
 }
 public void BatchDataTest()
 {
     AtomEntry target = new AtomEntry(); // TODO: Initialize to an appropriate value
     GDataBatchEntryData expected = new GDataBatchEntryData();
     GDataBatchEntryData actual;
     target.BatchData = expected;
     actual = target.BatchData;
     Assert.AreEqual(expected, actual);
 }