Author: fmantek Date: Fri Sep 21 04:43:38 2007 New Revision: 264 Modified: trunk/clients/cs/src/core/atombase.cs trunk/clients/cs/src/core/atomfeed.cs trunk/clients/cs/src/core/atomfeedentry.cs trunk/clients/cs/src/core/atomfeedparser.cs trunk/clients/cs/src/extensions/extcollections.cs trunk/clients/cs/src/unittests/caltest.cs trunk/clients/cs/src/unittests/objectmodelhelper.cs
Log: changed the collection classes to make subcollections easier... Modified: trunk/clients/cs/src/core/atombase.cs ============================================================================== --- trunk/clients/cs/src/core/atombase.cs (original) +++ trunk/clients/cs/src/core/atombase.cs Fri Sep 21 04:43:38 2007 @@ -502,10 +502,52 @@ /// <param name="parser">the parser is primarily used for nametable comparisons</param> /// <returns>AtomBase</returns> public virtual AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser) - { - throw new NotImplementedException("AtomBase CreateChild should NEVER be called" + reader.LocalName); - return null; + Object localname = reader.LocalName; + if (localname.Equals(parser.Nametable.Id)) + { + return new AtomId(); + } + else if (localname.Equals(parser.Nametable.Link)) + { + return new AtomLink(); + } + else if (localname.Equals(parser.Nametable.Icon)) + { + return new AtomIcon(); + } + else if (localname.Equals(parser.Nametable.Logo)) + { + return new AtomLogo(); + } else if (localname.Equals(parser.Nametable.Author)) + { + return new AtomPerson(AtomPersonType.Author); + } + else if (localname.Equals(parser.Nametable.Contributor)) + { + return new AtomPerson(AtomPersonType.Contributor); + } else if (localname.Equals(parser.Nametable.Title)) + { + return new AtomTextConstruct(AtomTextConstructElementType.Title); + } else if (localname.Equals(parser.Nametable.Subtitle)) + { + return new AtomTextConstruct(AtomTextConstructElementType.Subtitle); + } else if (localname.Equals(parser.Nametable.Rights)) + { + return new AtomTextConstruct(AtomTextConstructElementType.Rights); + } else if (localname.Equals(parser.Nametable.Summary)) + { + return new AtomTextConstruct(AtomTextConstructElementType.Summary); + + } else if (localname.Equals(parser.Nametable.Generator)) + { + return new AtomGenerator(); + } else if (localname.Equals(parser.Nametable.Category)) + { + return new AtomCategory(); + } + + throw new NotImplementedException("AtomBase CreateChild should NEVER be called for: " + reader.LocalName); } Modified: trunk/clients/cs/src/core/atomfeed.cs ============================================================================== --- trunk/clients/cs/src/core/atomfeed.cs (original) +++ trunk/clients/cs/src/core/atomfeed.cs Fri Sep 21 04:43:38 2007 @@ -190,25 +190,6 @@ ///////////////////////////////////////////////////////////////////////////// - /// <summary> - /// this is the subclassing method for AtomBase derived - /// classes to overload what childelements should be created - /// needed to create CustomLink type objects, like WebContentLink etc - /// </summary> - /// <param name="reader">The XmlReader that tells us what we are working with</param> - /// <param name="parser">the parser is primarily used for nametable comparisons</param> - /// <returns>AtomBase</returns> - public override AtomBase CreateAtomSubElement(XmlReader reader, AtomFeedParser parser) - { - Object localname = reader.LocalName; - - if ((localname.Equals(parser.Nametable.Link))) - { - return new AtomLink(); - } - return base.CreateAtomSubElement(reader, parser); - } - ////////////////////////////////////////////////////////////////////// /// <summary>tries to determine if the two feeds derive from the same source</summary> /// <param name="feedOne">the first feed</param> Modified: trunk/clients/cs/src/core/atomfeedentry.cs ============================================================================== --- trunk/clients/cs/src/core/atomfeedentry.cs (original) +++ trunk/clients/cs/src/core/atomfeedentry.cs Fri Sep 21 04:43:38 2007 @@ -826,12 +826,12 @@ { Object localname = reader.LocalName; - if ((localname.Equals(parser.Nametable.Link))) - { - return new AtomLink(); - } else if (localname.Equals(parser.Nametable.Source)) + if (localname.Equals(parser.Nametable.Source)) { return new AtomSource(); + } else if (localname.Equals(parser.Nametable.Content)) + { + return new AtomContent(); } return base.CreateAtomSubElement(reader, parser); Modified: trunk/clients/cs/src/core/atomfeedparser.cs ============================================================================== --- trunk/clients/cs/src/core/atomfeedparser.cs (original) +++ trunk/clients/cs/src/core/atomfeedparser.cs Fri Sep 21 04:43:38 2007 @@ -197,7 +197,7 @@ bool fSkip = true; if (localname.Equals(this.nameTable.Title)) { - source.Title = ParseTextConstruct(reader, AtomTextConstructElementType.Title); + source.Title = ParseTextConstruct(reader, source); } else if (localname.Equals(this.nameTable.Updated)) { @@ -211,44 +211,43 @@ } else if (localname.Equals(this.nameTable.Id)) { - source.Id = new AtomId(); + source.Id = source.CreateAtomSubElement(reader, this) as AtomId; ParseBaseLink(reader, source.Id); } else if (localname.Equals(this.nameTable.Icon)) { - source.Icon = new AtomIcon(); + source.Icon = source.CreateAtomSubElement(reader, this) as AtomIcon; ParseBaseLink(reader, source.Icon); } else if (localname.Equals(this.nameTable.Logo)) { - source.Logo = new AtomLogo(); + source.Logo = source.CreateAtomSubElement(reader, this) as AtomLogo; ParseBaseLink(reader, source.Logo); } - else if (localname.Equals(this.nameTable.Author)) { - source.Authors.Add(ParsePerson(reader, this.nameTable.Author)); + source.Authors.Add(ParsePerson(reader, source)); } else if (localname.Equals(this.nameTable.Contributor)) { - source.Contributors.Add(ParsePerson(reader, this.nameTable.Contributor)); + source.Contributors.Add(ParsePerson(reader, source)); } else if (localname.Equals(this.nameTable.Subtitle)) { - source.Subtitle = ParseTextConstruct(reader, AtomTextConstructElementType.Subtitle); + source.Subtitle = ParseTextConstruct(reader, source); } else if (localname.Equals(this.nameTable.Rights)) { - source.Rights = ParseTextConstruct(reader, AtomTextConstructElementType.Rights); + source.Rights = ParseTextConstruct(reader, source); } else if (localname.Equals(this.nameTable.Generator)) { - source.Generator = ParseGenerator(reader); + source.Generator = ParseGenerator(reader, source); } else if (localname.Equals(this.nameTable.Category)) { // need to make this another colleciton - source.Categories.Add(ParseCategory(reader)); + source.Categories.Add(ParseCategory(reader, source)); } else if (feed != null && localname.Equals(this.nameTable.Entry)) { @@ -460,33 +459,25 @@ ////////////////////////////////////////////////////////////////////// /// <summary>parses an author/person object</summary> /// <param name="reader"> an XmlReader positioned at the start of the author</param> - /// <param name="whoIsIt">indicates the localname to check for</param> + /// <param name="owner">the object containing the person</param> /// <returns> the created author object</returns> ////////////////////////////////////////////////////////////////////// - protected AtomPerson ParsePerson(XmlReader reader, object whoIsIt) + protected AtomPerson ParsePerson(XmlReader reader, AtomBase owner) { Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) { throw new ArgumentNullException("reader"); } - Tracing.Assert(whoIsIt != null, "whoIsIt should not be null"); - if (whoIsIt == null) + Tracing.Assert(owner != null, "owner should not be null"); + if (owner == null) { - throw new ArgumentNullException("whoIsIt"); + throw new ArgumentNullException("owner"); } + Tracing.TraceCall(); - AtomPerson author = null; object localname = null; - - if (whoIsIt.Equals(this.nameTable.Author)) - { - author = new AtomPerson(AtomPersonType.Author); - } - else - { - author = new AtomPerson(AtomPersonType.Contributor); - } + AtomPerson author = owner.CreateAtomSubElement(reader, this) as AtomPerson; ParseBasicAttributes(reader, author); @@ -529,27 +520,28 @@ ////////////////////////////////////////////////////////////////////// /// <summary>parses an xml stream to create an AtomCategory object</summary> /// <param name="reader">correctly positioned xmlreader</param> + /// <param name="owner">the object containing the person</param> /// <returns> the created AtomCategory object</returns> ////////////////////////////////////////////////////////////////////// - protected AtomCategory ParseCategory(XmlReader reader) + protected AtomCategory ParseCategory(XmlReader reader, AtomBase owner) { Tracing.TraceCall(); - AtomCategory category = null; Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) { throw new ArgumentNullException("reader"); } - object localname = reader.LocalName; - if (localname.Equals(this.nameTable.Category)) + AtomCategory category = owner.CreateAtomSubElement(reader, this) as AtomCategory; + + if (category != null) { category = new AtomCategory(); if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { - localname = reader.LocalName; + object localname = reader.LocalName; if (localname.Equals(this.nameTable.Term)) { category.Term = Utilities.DecodedValue(reader.Value); @@ -578,9 +570,10 @@ ////////////////////////////////////////////////////////////////////// /// <summary>creates an atomlink object</summary> /// <param name="reader">correctly positioned xmlreader</param> - /// <returns> the created AtomLink object</returns> + /// <param name="owner">the object containing the person</param> + /// <returns> the created AtomLink object</returns> ////////////////////////////////////////////////////////////////////// - protected AtomLink ParseLink(XmlReader reader, AtomBase parent) + protected AtomLink ParseLink(XmlReader reader, AtomBase owner) { Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) @@ -590,7 +583,7 @@ Tracing.TraceCall(); - AtomLink link = parent.CreateAtomSubElement(reader, this) as AtomLink; + AtomLink link = owner.CreateAtomSubElement(reader, this) as AtomLink; object localname = null; if (reader.HasAttributes) @@ -675,7 +668,7 @@ bool fSkip = true; if (localname.Equals(this.nameTable.Id)) { - entry.Id = new AtomId(); + entry.Id = entry.CreateAtomSubElement(reader, this) as AtomId; ParseBaseLink(reader, entry.Id); } else if (localname.Equals(this.nameTable.Link)) @@ -693,28 +686,28 @@ } else if (localname.Equals(this.nameTable.Author)) { - entry.Authors.Add(ParsePerson(reader, localname)); + entry.Authors.Add(ParsePerson(reader, entry)); } else if (localname.Equals(this.nameTable.Contributor)) { - entry.Contributors.Add(ParsePerson(reader, localname)); + entry.Contributors.Add(ParsePerson(reader, entry)); } else if (localname.Equals(this.nameTable.Rights)) { - entry.Rights = ParseTextConstruct(reader, AtomTextConstructElementType.Rights); + entry.Rights = ParseTextConstruct(reader, entry); } else if (localname.Equals(this.nameTable.Category)) { - AtomCategory category = ParseCategory(reader); + AtomCategory category = ParseCategory(reader, entry); entry.Categories.Add(category); } else if (localname.Equals(this.nameTable.Summary)) { - entry.Summary = ParseTextConstruct(reader, AtomTextConstructElementType.Summary); + entry.Summary = ParseTextConstruct(reader, entry); } else if (localname.Equals(this.nameTable.Content)) { - entry.Content = ParseContent(reader, out fSkip); + entry.Content = ParseContent(reader, entry, out fSkip); } else if (localname.Equals(this.nameTable.Source)) { @@ -723,7 +716,7 @@ } else if (localname.Equals(this.nameTable.Title)) { - entry.Title = ParseTextConstruct(reader, AtomTextConstructElementType.Title); + entry.Title = ParseTextConstruct(reader, entry); } // this will either move the reader to the end of an element, or, // if at the end, to the start of a new one. @@ -1040,10 +1033,10 @@ ////////////////////////////////////////////////////////////////////// /// <summary>parses an AtomTextConstruct</summary> /// <param name="reader">the xmlreader correctly positioned at the construct </param> - /// <param name="elementType">the type of element to create</param> + /// <param name="owner">the container element</param> /// <returns>the new text construct </returns> ////////////////////////////////////////////////////////////////////// - protected AtomTextConstruct ParseTextConstruct(XmlReader reader, AtomTextConstructElementType elementType) + protected AtomTextConstruct ParseTextConstruct(XmlReader reader, AtomBase owner) { Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) @@ -1051,12 +1044,8 @@ throw new ArgumentNullException("reader"); } - - AtomTextConstruct construct = null; - Tracing.TraceCall("Parsing atomTextConstruct"); - - construct = new AtomTextConstruct(elementType); + AtomTextConstruct construct = owner.CreateAtomSubElement(reader, this) as AtomTextConstruct; if (reader.NodeType == XmlNodeType.Element) { @@ -1069,7 +1058,7 @@ if (attributeName.Equals(this.nameTable.Type)) { construct.Type = (AtomTextConstructType)Enum.Parse( - typeof(AtomTextConstructType), Utilities.DecodedValue(reader.Value), true); + typeof(AtomTextConstructType), Utilities.DecodedValue(reader.Value), true); } else { @@ -1099,9 +1088,10 @@ ////////////////////////////////////////////////////////////////////// /// <summary>parses an AtomGenerator</summary> /// <param name="reader">the xmlreader correctly positioned at the generator </param> + /// <param name="owner">the container element</param> /// <returns> </returns> ////////////////////////////////////////////////////////////////////// - protected AtomGenerator ParseGenerator(XmlReader reader) + protected AtomGenerator ParseGenerator(XmlReader reader, AtomBase owner) { // atomGenerator = element atom:generator { @@ -1118,13 +1108,9 @@ } Tracing.TraceCall(); - AtomGenerator generator = null; - object localname = reader.LocalName; - - if (localname.Equals(this.nameTable.Generator)) + AtomGenerator generator = owner.CreateAtomSubElement(reader, this) as AtomGenerator; + if (generator != null) { - generator = new AtomGenerator(); - generator.Text = Utilities.DecodedValue(reader.ReadString()); if (reader.HasAttributes) { @@ -1157,10 +1143,11 @@ ////////////////////////////////////////////////////////////////////// /// <summary>creates an AtomContent object by parsing an xml stream</summary> /// <param name="reader">a XMLReader positioned correctly </param> - /// <param name="skipNode">a boolen indicating if the node needs to be skipped, or not</param> + /// <param name="owner">the container element</param> + /// <param name="skipNode">a boolen indicating if the node needs to be skipped, or not</param> /// <returns> null or an AtomContent object</returns> ////////////////////////////////////////////////////////////////////// - protected AtomContent ParseContent(XmlReader reader, out bool skipNode) + protected AtomContent ParseContent(XmlReader reader, AtomBase owner, out bool skipNode) { Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) @@ -1171,18 +1158,15 @@ // by default, skip to the next node after this routine skipNode = true; - AtomContent content = null; - object localname = reader.LocalName; - + AtomContent content = owner.CreateAtomSubElement(reader, this) as AtomContent; Tracing.TraceCall(); - if (localname.Equals(this.nameTable.Content)) + if (content != null) { - content = new AtomContent(); if (reader.HasAttributes) { while (reader.MoveToNextAttribute()) { - localname = reader.LocalName; + object localname = reader.LocalName; if (localname.Equals(this.nameTable.Type)) { content.Type = Utilities.DecodedValue(reader.Value); Modified: trunk/clients/cs/src/extensions/extcollections.cs ============================================================================== --- trunk/clients/cs/src/extensions/extcollections.cs (original) +++ trunk/clients/cs/src/extensions/extcollections.cs Fri Sep 21 04:43:38 2007 @@ -31,29 +31,99 @@ namespace Google.GData.Extensions { - ////////////////////////////////////////////////////////////////////// - /// <summary>Typed collection for When Extensions.</summary> - ////////////////////////////////////////////////////////////////////// - public class WhenCollection : CollectionBase + /// <summary> + /// base class to take an object pointer with extension information + /// and expose a localname/namespace subset as a collection + /// that still works on the original + /// </summary> + public class ExtensionCollection : CollectionBase { - /// <summary>holds the owning feed</summary> + /// <summary>holds the owning feed</summary> private AtomBase atomElement; - private WhenCollection() + protected ExtensionCollection() { } - /// <summary>constructor</summary> - public WhenCollection(AtomBase atomElement) : base() + /// <summary> + /// takes the base object, and the localname/ns combo to look for + /// will copy objects to an internal array for caching. Note that when the external + /// ExtensionList is modified, this will have no effect on this copy + /// </summary> + /// <param name="atomElement">the base element holding the extension list</param> + /// <param name="localName">the local name of the extension</param> + /// <param name="ns">the namespace</param> + public ExtensionCollection(AtomBase atomElement, string localName, string ns) : base() { this.atomElement = atomElement; - ArrayList arr = atomElement.FindExtensions(GDataParserNameTable.XmlWhenElement, BaseNameTable.gNamespace); + ArrayList arr = atomElement.FindExtensions(localName, ns); foreach (object o in arr ) { List.Add(o); } } + protected void setItem(int index, object item) + { + if (List[index] != null) + { + this.atomElement.ExtensionElements.Remove(List[index]); + } + List[index] = item; + if (item != null) + { + this.atomElement.ExtensionElements.Add(item); + } + } + + + public int Add(object value) + { + this.atomElement.ExtensionElements.Add(value); + return( List.Add( value ) ); + } + + public void Insert( int index, object value ) + { + if (this.atomElement.ExtensionElements.Contains(value)) + { + this.atomElement.ExtensionElements.Remove(value); + } + this.atomElement.ExtensionElements.Add(value); + List.Insert( index, value ); + } + + public void Remove( object value ) + { + this.atomElement.ExtensionElements.Remove(value); + List.Remove( value ); + } + + /// <summary>standard override OnClear, to remove the objects from the extension list</summary> + protected override void OnClear() + { + for (int i=0; i< this.Count;i++) + { + this.atomElement.ExtensionElements.Remove((When)List[i]); + } + } + } + + ////////////////////////////////////////////////////////////////////// + /// <summary>Typed collection for When Extensions.</summary> + ////////////////////////////////////////////////////////////////////// + public class WhenCollection : ExtensionCollection + { + private WhenCollection() : base() + { + } + + /// <summary>constructor</summary> + public WhenCollection(AtomBase atomElement) + : base(atomElement, GDataParserNameTable.XmlWhenElement, BaseNameTable.gNamespace) + { + } + /// <summary>standard typed accessor method </summary> public When this[ int index ] { @@ -63,18 +133,15 @@ } set { - this.atomElement.ExtensionElements.Remove((When)List[index]); - List[index] = value; - this.atomElement.ExtensionElements.Add(value); + setItem(index, value); } } /// <summary>standard typed add method </summary> public int Add( When value ) { - this.atomElement.ExtensionElements.Add(value); - return( List.Add( value ) ); - } + return base.Add(value); + } /// <summary>standard typed indexOf method </summary> public int IndexOf( When value ) @@ -85,19 +152,13 @@ /// <summary>standard typed insert method </summary> public void Insert( int index, When value ) { - if (this.atomElement.ExtensionElements.Contains(value)) - { - this.atomElement.ExtensionElements.Remove(value); - } - this.atomElement.ExtensionElements.Add(value); - List.Insert( index, value ); + base.Insert(index, value); } /// <summary>standard typed remove method </summary> public void Remove( When value ) { - this.atomElement.ExtensionElements.Remove(value); - List.Remove( value ); + base.Remove(value); } /// <summary>standard typed Contains method </summary> @@ -114,35 +175,25 @@ throw new ArgumentException( "value must be of type Google.GData.Extensions.When.", "value" ); } - /// <summary>standard override OnClear, to remove the objects from the extension list</summary> - protected override void OnClear() - { - for (int i=0; i< this.Count;i++) - { - this.atomElement.ExtensionElements.Remove((When)List[i]); - } - } } ////////////////////////////////////////////////////////////////////// /// <summary>Typed collection for Where Extensions.</summary> ////////////////////////////////////////////////////////////////////// - public class WhereCollection : CollectionBase + public class WhereCollection : ExtensionCollection { - /// <summary>holds the owning feed</summary> - private AtomBase atomElement; - private WhereCollection() + private WhereCollection() : base() { } /// <summary>constructor</summary> - public WhereCollection(AtomBase atomElement) - : base() + public WhereCollection(AtomBase atomElement) + : base(atomElement, GDataParserNameTable.XmlWhereElement, BaseNameTable.gNamespace) { - this.atomElement = atomElement; } + /// <summary>standard typed accessor method </summary> public Where this[int index] { @@ -152,17 +203,14 @@ } set { - this.atomElement.ExtensionElements.Remove((Where)List[index]); - List[index] = value; - this.atomElement.ExtensionElements.Add(value); + setItem(index, value); } } /// <summary>standard typed add method </summary> public int Add(Where value) { - this.atomElement.ExtensionElements.Add(value); - return (List.Add(value)); + return base.Add(value); } /// <summary>standard typed indexOf method </summary> @@ -174,18 +222,14 @@ /// <summary>standard typed insert method </summary> public void Insert(int index, Where value) { - if (this.atomElement.ExtensionElements.Contains(value)){ - this.atomElement.ExtensionElements.Remove(value); - } - this.atomElement.ExtensionElements.Add(value); - List.Insert(index, value); + base.Insert(index, value); + } /// <summary>standard typed remove method </summary> public void Remove(Where value) { - this.atomElement.ExtensionElements.Remove(value); - List.Remove(value); + base.Remove(value); } /// <summary>standard typed Contains method </summary> @@ -201,35 +245,24 @@ if (value as Where == null) throw new ArgumentException("value must be of type Google.GData.Extensions.Where.", "value"); } - - /// <summary>standard override OnClear, to remove the objects from the extension list</summary> - protected override void OnClear() - { - for (int i=0; i< this.Count;i++) - { - this.atomElement.ExtensionElements.Remove((Where)List[i]); - } - } - } ////////////////////////////////////////////////////////////////////// /// <summary>Typed collection for Who Extensions.</summary> ////////////////////////////////////////////////////////////////////// - public class WhoCollection : CollectionBase + public class WhoCollection : ExtensionCollection { /// <summary>holds the owning feed</summary> private AtomBase atomElement; - private WhoCollection() + private WhoCollection() : base() { } - /// <summary>constructor</summary> - public WhoCollection(AtomBase atomElement) - : base() + /// <summary>constructor</summary> + public WhoCollection(AtomBase atomElement) + : base(atomElement, GDataParserNameTable.XmlWhoElement, BaseNameTable.gNamespace) { - this.atomElement = atomElement; } /// <summary>standard typed accessor method </summary> @@ -241,17 +274,14 @@ } set { - this.atomElement.ExtensionElements.Remove((Who)List[index]); - List[index] = value; - this.atomElement.ExtensionElements.Add(value); + setItem(index,value); } } /// <summary>standard typed add method </summary> public int Add(Who value) { - this.atomElement.ExtensionElements.Add(value); - return (List.Add(value)); + return base.Add(value); } /// <summary>standard typed indexOf method </summary> @@ -263,19 +293,13 @@ /// <summary>standard typed insert method </summary> public void Insert(int index, Who value) { - if (this.atomElement.ExtensionElements.Contains(value)) - { - this.atomElement.ExtensionElements.Remove(value); - } - this.atomElement.ExtensionElements.Add(value); - List.Insert(index, value); + base.Insert(index, value); } /// <summary>standard typed remove method </summary> public void Remove(Who value) { - this.atomElement.ExtensionElements.Remove(value); - List.Remove(value); + base.Remove(value); } /// <summary>standard typed Contains method </summary> @@ -291,16 +315,6 @@ if (value as Who == null) throw new ArgumentException("value must be of type Google.GData.Extensions.Who.", "value"); } - - /// <summary>standard override OnClear, to remove the objects from the extension list</summary> - protected override void OnClear() - { - for (int i=0; i< this.Count;i++) - { - this.atomElement.ExtensionElements.Remove((Who)List[i]); - } - } - } ///////////////////////////////////////////////////////////////////////////// Modified: trunk/clients/cs/src/unittests/caltest.cs ============================================================================== --- trunk/clients/cs/src/unittests/caltest.cs (original) +++ trunk/clients/cs/src/unittests/caltest.cs Fri Sep 21 04:43:38 2007 @@ -170,11 +170,8 @@ AtomEntry sameGuy = newFeed.Entries[0]; Assert.IsTrue(sameGuy.Title.Text.Equals(newEntry.Title.Text), "both titles should be identical"); - } - calFeed = service.Query(query); - Assert.AreEqual(iCount, calFeed.Entries.Count, "Feed should have one more entry, it has: " + calFeed.Entries.Count); if (calFeed != null && calFeed.Entries.Count > 0) @@ -329,10 +326,12 @@ entry.Title.Text = strTitle; EventEntry newEntry = (EventEntry) calFeed.Insert(entry); - Reminder rNew = null; - Reminder rOld = null; + iCount++; + Tracing.TraceMsg("Created calendar entry"); + Reminder rNew = null; + Reminder rOld = null; if (newEntry.Reminders.Count > 0) { rNew = newEntry.Reminders[0] as Reminder; @@ -344,15 +343,37 @@ Assert.IsTrue(rNew != null, "Reminder should not be NULL);"); Assert.IsTrue(rOld != null, "Original Reminder should not be NULL);"); - - Assert.AreEqual(rNew.Minutes, rOld.Minutes, "Reminder time should be identical"); - iCount++; - Tracing.TraceMsg("Created calendar entry"); + + Where wOldOne, wOldTwo; + Where wNewOne, wNewTwo; + + Assert.IsTrue(entry.Locations.Count == 2, "entry should have 2 locations"); + Assert.IsTrue(newEntry.Locations.Count == 2, "new entry should have 2 locations"); + + + if (entry.Locations.Count > 1) + { + wOldOne = entry.Locations[0]; + wOldTwo = entry.Locations[1]; + + if (newEntry.Locations.Count > 1) + { + wNewOne = newEntry.Locations[0]; + wNewTwo = newEntry.Locations[1]; + Assert.IsTrue(wOldOne != null, "Where oldOne should not be NULL);"); + Assert.IsTrue(wOldTwo != null, "Where oldTwo should not be NULL);"); + Assert.IsTrue(wNewOne != null, "Where newOne should not be NULL);"); + Assert.IsTrue(wNewTwo != null, "Where newTwoOne should not be NULL);"); + Assert.IsTrue(wOldOne.ValueString == wNewOne.ValueString, "location one should be identical"); + Assert.IsTrue(wOldTwo.ValueString == wNewTwo.ValueString, "location one should be identical"); + } + } + + newEntry.Content.Content = "Updated.."; newEntry.Update(); - // try to get just that guy..... FeedQuery singleQuery = new FeedQuery(); Modified: trunk/clients/cs/src/unittests/objectmodelhelper.cs ============================================================================== --- trunk/clients/cs/src/unittests/objectmodelhelper.cs (original) +++ trunk/clients/cs/src/unittests/objectmodelhelper.cs Fri Sep 21 04:43:38 2007 @@ -141,7 +141,7 @@ entry.Reminder.Minutes = DEFAULT_REMINDER_TIME; Who someone = new Who(); - someone.ValueString = "[EMAIL PROTECTED]"; + someone.ValueString = "[EMAIL PROTECTED]"; Who.AttendeeStatus status = new Who.AttendeeStatus(); status.Value = "event.accepted"; someone.Attendee_Status = status; @@ -153,9 +153,10 @@ Where newPlace = new Where(); newPlace.ValueString = "A really nice place"; entry.Locations.Add(newPlace); - - - + newPlace = new Where(); + newPlace.ValueString = "Another really nice place"; + newPlace.Rel = Where.RelType.EVENT_ALTERNATE; + entry.Locations.Add(newPlace); return entry; } ///////////////////////////////////////////////////////////////////////////// @@ -726,9 +727,5 @@ } } ///////////////////////////////////////////////////////////////////////////// - - - } - } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Data API" group. To post to this group, send email to google-help-dataapi@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---