///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>takes the updated entry returned and sets the properties to this object</summary> /// <param name="updatedEntry"> </param> ////////////////////////////////////////////////////////////////////// protected void CopyEntry(AtomEntry updatedEntry) { Tracing.Assert(updatedEntry != null, "updatedEntry should not be null"); if (updatedEntry == null) { throw new ArgumentNullException("updatedEntry"); } this.title = updatedEntry.Title; this.authors = updatedEntry.Authors; this.id = updatedEntry.Id; this.links = updatedEntry.Links; this.lastUpdateDate = updatedEntry.Updated; this.publicationDate = updatedEntry.Published; this.authors = updatedEntry.Authors; this.rights = updatedEntry.Rights; this.categories = updatedEntry.Categories; this.summary = updatedEntry.Summary; this.content = updatedEntry.Content; this.source = updatedEntry.Source; this.ExtensionElements.Clear(); foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements) { this.ExtensionElements.Add(extension); } }
///<summary>Standard type converter method</summary> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { AtomSource atomSource = value as AtomSource; if (destinationType == typeof(System.String) && atomSource != null) { return("Feed: " + atomSource.Title); } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary>parses xml to fill a precreated AtomSource object (might be a feed)</summary> /// <param name="reader">correctly positioned reader</param> /// <param name="source">created source object to be filled</param> /// <returns> </returns> protected void ParseSource(XmlReader reader, AtomSource source) { Tracing.Assert(reader != null, "reader should not be null"); if (reader == null) { throw new ArgumentNullException("reader"); } Tracing.Assert(source != null, "source should not be null"); if (source == null) { throw new ArgumentNullException("source"); } Tracing.TraceCall(); int depth = -1; ParseBasicAttributes(reader, source); while (NextChildElement(reader, ref depth)) { object localname = reader.LocalName; AtomFeed feed = source as AtomFeed; if (IsCurrentNameSpace(reader, BaseNameTable.NSAtom)) { if (localname.Equals(this.nameTable.Title)) { source.Title = ParseTextConstruct(reader, source); } else if (localname.Equals(this.nameTable.Updated)) { source.Updated = DateTime.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture); } else if (localname.Equals(this.nameTable.Link)) { source.Links.Add(ParseLink(reader, source)); } else if (localname.Equals(this.nameTable.Id)) { source.Id = source.CreateAtomSubElement(reader, this) as AtomId; ParseBaseLink(reader, source.Id); } else if (localname.Equals(this.nameTable.Icon)) { source.Icon = source.CreateAtomSubElement(reader, this) as AtomIcon; ParseBaseLink(reader, source.Icon); } else if (localname.Equals(this.nameTable.Logo)) { source.Logo = source.CreateAtomSubElement(reader, this) as AtomLogo; ParseBaseLink(reader, source.Logo); } else if (localname.Equals(this.nameTable.Author)) { source.Authors.Add(ParsePerson(reader, source)); } else if (localname.Equals(this.nameTable.Contributor)) { source.Contributors.Add(ParsePerson(reader, source)); } else if (localname.Equals(this.nameTable.Subtitle)) { source.Subtitle = ParseTextConstruct(reader, source); } else if (localname.Equals(this.nameTable.Rights)) { source.Rights = ParseTextConstruct(reader, source); } else if (localname.Equals(this.nameTable.Generator)) { source.Generator = ParseGenerator(reader, source); } else if (localname.Equals(this.nameTable.Category)) { // need to make this another colleciton source.Categories.Add(ParseCategory(reader, source)); } else if (feed != null && localname.Equals(this.nameTable.Entry)) { ParseEntry(reader); } // this will either move the reader to the end of an element // if at the end, to the start of a new one. reader.Read(); } else if (feed != null && IsCurrentNameSpace(reader, BaseNameTable.gBatchNamespace)) { // parse the google batch extensions if they are there ParseBatch(reader, feed); } else if (feed != null && IsCurrentNameSpace(reader, BaseNameTable.OpenSearchNamespace(this.versionInfo))) { if (localname.Equals(this.nameTable.TotalResults)) { feed.TotalResults = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture); } else if (localname.Equals(this.nameTable.StartIndex)) { feed.StartIndex = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture); } else if (localname.Equals(this.nameTable.ItemsPerPage)) { feed.ItemsPerPage = int.Parse(Utilities.DecodedValue(reader.ReadString()), CultureInfo.InvariantCulture); } } else { // default extension parsing. ParseExtensionElements(reader, source); } } return; }
public void SourceTest() { AtomEntry target = new AtomEntry(); // TODO: Initialize to an appropriate value AtomSource expected = new AtomSource(); AtomSource actual; target.Source = expected; actual = target.Source; Assert.AreEqual(expected, actual); }
public void RightsTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value target.Rights = new AtomTextConstruct(AtomTextConstructElementType.Rights, "test"); Assert.AreEqual(target.Rights.Text, "test"); }
public void UpdatedTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value DateTime expected = DateTime.Now; DateTime actual; target.Updated = expected; actual = target.Updated; Assert.AreEqual(expected, actual); }
public void AtomSourceConstructorTest1() { AtomSource target = new AtomSource(); Assert.IsNotNull(target); }
public void AtomSourceConstructorTest() { AtomFeed feed = new AtomFeed(new Uri("http://www.test.com/"), null); feed.Title = new AtomTextConstruct(AtomTextConstructElementType.Title, "Title"); AtomSource target = new AtomSource(feed); Assert.AreEqual(feed.Title.Text, target.Title.Text); }
public void GeneratorTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomGenerator expected = new AtomGenerator(); AtomGenerator actual; target.Generator = expected; actual = target.Generator; Assert.AreEqual(expected, actual); }
public void AuthorsTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value Assert.IsNotNull(target.Authors); }
public void IconTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomIcon expected = new AtomIcon(); AtomIcon actual; target.Icon = expected; actual = target.Icon; Assert.AreEqual(expected, actual); }
public void IdTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomId expected = new AtomId(); AtomId actual; target.Id = expected; actual = target.Id; Assert.AreEqual(expected, actual); }
public void LogoTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value AtomLogo expected = new AtomLogo(); AtomLogo actual; target.Logo = expected; actual = target.Logo; Assert.AreEqual(expected, actual); }
/// <summary>takes the updated entry returned and sets the properties to this object</summary> /// <param name="updatedEntry"> </param> protected void CopyEntry(AtomEntry updatedEntry) { Tracing.Assert(updatedEntry != null, "updatedEntry should not be null"); if (updatedEntry == null) { throw new ArgumentNullException("updatedEntry"); } this.title = updatedEntry.Title; this.authors = updatedEntry.Authors; this.id = updatedEntry.Id; this.links = updatedEntry.Links; this.lastUpdateDate = updatedEntry.Updated; this.publicationDate = updatedEntry.Published; this.authors = updatedEntry.Authors; this.rights = updatedEntry.Rights; this.categories = updatedEntry.Categories; this.summary = updatedEntry.Summary; this.content = updatedEntry.Content; this.source = updatedEntry.Source; this.ExtensionElements.Clear(); foreach (IExtensionElementFactory extension in updatedEntry.ExtensionElements) { this.ExtensionElements.Add(extension); } }
public void XmlNameTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value Assert.AreEqual(target.XmlName, AtomParserNameTable.XmlSourceElement); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>compares 2 source objects</summary> /// <param name="theOne">the One source</param> /// <param name="theOther">the Other source</param> /// <returns>true if identical </returns> ////////////////////////////////////////////////////////////////////// public static bool IsSourceIdentical(AtomSource theOne, AtomSource theOther) { Tracing.TraceInfo("Comparing source objects"); if (theOne == null && theOther == null) { return true; } if (ObjectModelHelper.IsBaseIdentical(theOne, theOther)==false) { return false; } Tracing.TraceInfo("Source: comparing Authors collections"); if (ObjectModelHelper.IsPersonCollectionIdentical(theOne.Authors, theOther.Authors)==false) { return false; } Tracing.TraceInfo("Source: comparing Contributors collections"); if (ObjectModelHelper.IsPersonCollectionIdentical(theOne.Contributors, theOther.Contributors)==false) { return false; } Tracing.TraceInfo("Source: comparing categories collections"); if (ObjectModelHelper.IsCategoryCollectionIdentical(theOne.Categories, theOther.Categories)==false) { return false; } Tracing.TraceInfo("Source: comparing links collections"); if (ObjectModelHelper.IsLinkCollectionIdentical(theOne.Links, theOther.Links)==false) { return false; } if (ObjectModelHelper.IsTextConstructIdentical(theOne.Title, theOther.Title)==false) { return false; } if (ObjectModelHelper.IsTextConstructIdentical(theOne.Rights, theOther.Rights)==false) { return false; } if (ObjectModelHelper.IsTextConstructIdentical(theOne.Subtitle, theOther.Subtitle)==false) { return false; } if (ObjectModelHelper.IsBaseLinkIdentical(theOne.Id, theOther.Id)==false) { return false; } if (ObjectModelHelper.IsGeneratorIdentical(theOne.Generator, theOther.Generator)==false) { return false; } if (ObjectModelHelper.IsBaseLinkIdentical(theOne.Icon, theOther.Icon)==false) { return false; } if (ObjectModelHelper.IsBaseLinkIdentical(theOne.Logo, theOther.Logo)==false) { return false; } return true; }
public void SubtitleTest() { AtomSource target = new AtomSource(); // TODO: Initialize to an appropriate value target.Subtitle = new AtomTextConstruct(AtomTextConstructElementType.Subtitle, "test"); Assert.AreEqual(target.Subtitle.Text, "test"); }