//============================================================ // ICOMPARABLE IMPLEMENTATION //============================================================ #region CompareTo(object obj) /// <summary> /// Compares the current instance with another object of the same type. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception> public int CompareTo(object obj) { //------------------------------------------------------------ // If target is a null reference, instance is greater //------------------------------------------------------------ if (obj == null) { return(1); } //------------------------------------------------------------ // Determine comparison result using property state of objects //------------------------------------------------------------ PheedSyndicationExtension value = obj as PheedSyndicationExtension; if (value != null) { int result = Uri.Compare(this.Context.Source, value.Context.Source, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); result = result | Uri.Compare(this.Context.Thumbnail, value.Context.Thumbnail, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); return(result); } else { throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj"); } }
/// <summary> /// Compares the current instance with another object of the same type. /// </summary> /// <param name="obj">An object to compare with this instance.</param> /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared.</returns> /// <exception cref="ArgumentException">The <paramref name="obj"/> is not the expected <see cref="Type"/>.</exception> public int CompareTo(object obj) { if (obj == null) { return(1); } PheedSyndicationExtension value = obj as PheedSyndicationExtension; if (value != null) { int result = Uri.Compare(this.Context.Source, value.Context.Source, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); result = result | Uri.Compare(this.Context.Thumbnail, value.Context.Thumbnail, UriComponents.AbsoluteUri, UriFormat.SafeUnescaped, StringComparison.OrdinalIgnoreCase); return(result); } else { throw new ArgumentException(String.Format(null, "obj is not of type {0}, type was found to be '{1}'.", this.GetType().FullName, obj.GetType().FullName), "obj"); } }
public void PheedSyndicationExtensionConstructorTest() { PheedSyndicationExtension target = new PheedSyndicationExtension(); Assert.IsNotNull(target); Assert.IsInstanceOfType(target, typeof(PheedSyndicationExtension)); }
private PheedSyndicationExtension CreateExtension2() { var nyc = new PheedSyndicationExtension(); nyc.Context.Source = new Uri("http://www.example.net"); nyc.Context.Thumbnail = new Uri("http://www.example.net/thumbnail.png"); return nyc; }
public void Pheed_LoadTest() { PheedSyndicationExtension target = new PheedSyndicationExtension(); // TODO: Initialize to an appropriate value var nt = new NameTable(); var ns = new XmlNamespaceManager(nt); var xpc = new XmlParserContext(nt, ns, "US-en",XmlSpace.Default); var strXml = ExtensionTestUtil.GetWrappedXml(namespc, strExtXml); using (XmlReader reader = new XmlTextReader(strXml, XmlNodeType.Document, xpc) ) { #if false //var document = new XPathDocument(reader); //var nav = document.CreateNavigator(); //nav.Select("//item"); do { if (!reader.Read()) break; } while (reader.NodeType != XmlNodeType.EndElement || reader.Name != "webMaster"); bool expected = true; bool actual; actual = target.Load(reader); Assert.AreEqual(expected, actual); #else RssFeed feed = new RssFeed(); feed.Load(reader); #endif } }
public void Pheed_CreateXmlTest() { var pheed= new PheedSyndicationExtension(); pheed.Context.Source = new Uri("http://www.example.com"); pheed.Context.Thumbnail = new Uri("http://www.example.com/thumbnail.jpg"); var actual = ExtensionTestUtil.AddExtensionToXml(pheed); string expected = ExtensionTestUtil.GetWrappedXml(namespc, strExtXml); Assert.AreEqual(expected, actual); }