示例#1
0
        private static void MakeDocumentAssertions(IXmlElement xhtml)
        {
            const string paragraphContent = "How stable will the West Antarctic Ice sheet be as";

            Assert.IsNotNull(xhtml);
            Assert.AreEqual(2, xhtml.Children.OfType<IComment>().Count());

            var declaration = xhtml.Children.OfType<IDeclaration>().FirstOrDefault();
            Assert.IsNotNull(declaration);
            Assert.AreEqual("UTF-8", declaration.Encoding);
            Assert.AreEqual("1.0", declaration.Version);

            var root = xhtml.Children.OfType<IElement>().FirstOrDefault();
            Assert.IsNotNull(root);
            Assert.AreEqual("html", root.Name.ToString());
            Assert.AreEqual(8, xhtml.Where<IElement>(x => x.Name.ToString() == "link").Count());
            Assert.AreEqual(277, xhtml.Where<IElement>(x => x.Name.ToString() == "div").Count());
            var p = xhtml.Where<IElement>(x => x.Name.ToString() == "p" && x.ToString().Contains(paragraphContent)).FirstOrDefault();
            Assert.IsNotNull(p);
        }
示例#2
0
        private static void MakeDocumentAssertions(IXmlElement xhtml)
        {
            const string paragraphContent = "How stable will the West Antarctic Ice sheet be as";

            Assert.IsNotNull(xhtml);
            Assert.AreEqual(2, xhtml.Children.OfType <IComment>().Count());

            var declaration = xhtml.Children.OfType <IDeclaration>().FirstOrDefault();

            Assert.IsNotNull(declaration);
            Assert.AreEqual("UTF-8", declaration.Encoding);
            Assert.AreEqual("1.0", declaration.Version);

            var root = xhtml.Children.OfType <IElement>().FirstOrDefault();

            Assert.IsNotNull(root);
            Assert.AreEqual("html", root.Name.ToString());
            Assert.AreEqual(8, xhtml.Where <IElement>(x => x.Name.ToString() == "link").Count());
            Assert.AreEqual(277, xhtml.Where <IElement>(x => x.Name.ToString() == "div").Count());
            var p = xhtml.Where <IElement>(x => x.Name.ToString() == "p" && x.ToString().Contains(paragraphContent)).FirstOrDefault();

            Assert.IsNotNull(p);
        }
示例#3
0
        private void MakeAtomXmlAssertions(IXmlElement xml)
        {
            const string atomNamespace       = "http://www.w3.org/2005/Atom";
            const string openSearchNamespace = "http://a9.com/-/spec/opensearchrss/1.0/";

            Assert.IsNotNull(xml);
            var feed = xml.Where <IElement>(x => x.Name.LocalPart == "feed").FirstOrDefault();

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.CurrentNamespace);
            Assert.AreEqual(atomNamespace, feed.CurrentNamespace.Identifier.ToString());
            var totalResults = feed.Where <IOpenSearchTotalResults>(x => true);

            Assert.AreEqual(2, totalResults.Count());
            Assert.IsTrue(totalResults.All(x => x.CurrentNamespace != null && x.CurrentNamespace.Identifier.ToString() == openSearchNamespace && x.Content > 0));
        }
示例#4
0
        private void MakeRssFeedAssertions(IXmlElement document)
        {
            #region Constants

            const string version = "2.0";
            const string title = "Ars Technica";
            const string link = "http://arstechnica.com/index.php";
            const string description = "The Art of Technology";
            var language = LanguageTag.Parse("en");
            var lastBuildDate = new DateTime(2011, 6, 29, 18, 45, 05); //Wed, 29 Jun 2011 18:45:05 +0000
            const string generator = "http://www.sixapart.com/movabletype/";
            const string docs = "http://www.rssboard.org/rss-specification";
            const string copyright = "Copyright 2011 Conde Nast Digital. The contents of this feed are available for non-commercial use only.";
            var pubDate = new DateTime(2011, 6, 4, 9, 14, 58); //Sat, 4 Jun 2011 09:14:58 +0000
            const string managingEditor = "[email protected] (Ken Fisher)";
            const string webMaster = "[email protected] (Clint Ecker)";

            const string categoryDomain = "http://www.sixapart.com/ns/types#category";
            const string categoryName = "News";

            const string cloudDomain = "radio.xmlstoragesystem.com";
            const int cloudPort = 80;
            const string cloudPath = "/RPC2";
            const string cloudProc = "xmlStorageSystem.rssPleaseNotify";
            var cloudProcotol = RssCloudProtocol.xml_rpc;

            const int ttl = 45;

            const string imageUrl = "http://static.arstechnica.net//public/v6/styles/light/images/masthead/logo.png?1309476728";
            const string imageTitle = "Ars Technica";
            const string imageLink = "http://arstechnica.com/index.php";
            const int imageHeight = 169;
            const int imageWidth = 300;
            const string imageDescription = "The Art of Technology";

            const string ratingExcerpt = "'http://www.gcf.org/v2.5' labels";

            const string textInputTitle = "Contact Us";
            const string textInputDescription = "Email us with feedback";
            const string textInputName = "Submit";
            const string textInputLink = "http://arstechnica.com/contact-us.php";

            var skipHours = new List<Hour> { Hour.Zero, Hour.One, Hour.Two, Hour.Twelve, Hour.Thirteen, Hour.Nineteen, Hour.TwentyThree };
            var skipDays = new List<Day> { Day.Sunday, Day.Thursday, Day.Saturday };

            //const string ext1Prefix = "dc";
            //const string ext1Name = "title";
            //const string ext1Namespace = "http://purl.org/dc/elements/1.1/";

            const string item1Title = "Impressions from Uncharted 3: Drake's Deception's open beta ";
            const string item1Author = "[email protected] (Josh McIllwain)";
            //const string item1MediaContentUrl = "http://static.arstechnica.net/assets/2011/06/uncharted-3-thumb-300x169-23017-f.jpg";
            const string item1Guid = "http://arstechnica.com/gaming/news/2011/06/impressions-from-uncharted-3-drakes-deceptions-open-beta.ars?utm_source=rss&utm_medium=rss&utm_campaign=rss";
            var item1PubDate = new DateTime(2011, 6, 29, 16, 47, 00); //Wed, 29 Jun 2011 11:47:00 -0500

            #endregion

            var feed = document.Root as IRssFeed;

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.Channel);
            Assert.AreEqual(version, feed.Version);
            Assert.AreEqual(2, document.Where<IStyleSheet>(x => x != null).Count());
            Assert.AreEqual(3, feed.Namespaces.Count());

            Assert.AreEqual(title, feed.Channel.Title);
            Assert.AreEqual(link, feed.Channel.Link.ToString());
            Assert.AreEqual(description, feed.Channel.Description);
            Assert.AreEqual(language.PrimaryLanguage, feed.Channel.Language.PrimaryLanguage);
            Assert.AreEqual(lastBuildDate, feed.Channel.LastBuildDate);
            Assert.AreEqual(generator, feed.Channel.Generator);
            Assert.AreEqual(docs, feed.Channel.Docs.ToString());
            Assert.AreEqual(copyright, feed.Channel.Copyright);
            Assert.AreEqual(pubDate, feed.Channel.PubDate);
            Assert.AreEqual(managingEditor, feed.Channel.ManagingEditor);
            Assert.AreEqual(webMaster, feed.Channel.WebMaster);
            Assert.IsNotNull(feed.Channel.Cloud);
            Assert.AreEqual(cloudDomain, feed.Channel.Cloud.Domain);
            Assert.AreEqual(cloudPort, feed.Channel.Cloud.Port);
            Assert.AreEqual(cloudPath, feed.Channel.Cloud.Path);
            Assert.AreEqual(cloudProc, feed.Channel.Cloud.RegisterProcedure);
            Assert.AreEqual(cloudProcotol, feed.Channel.Cloud.Protocol);
            Assert.AreEqual(ttl, feed.Channel.Ttl.TotalMinutes);
            Assert.IsNotNull(feed.Channel.Image);
            Assert.AreEqual(imageUrl, feed.Channel.Image.Url.ToString());
            Assert.AreEqual(imageTitle, feed.Channel.Image.Title);
            Assert.AreEqual(imageLink, feed.Channel.Image.Link.ToString());
            Assert.AreEqual(imageHeight, feed.Channel.Image.Height);
            Assert.AreEqual(imageWidth, feed.Channel.Image.Width);
            Assert.AreEqual(imageDescription, feed.Channel.Image.Description);
            Assert.IsNotNull(feed.Channel.Rating);
            Assert.IsTrue(feed.Channel.Rating.Contains(ratingExcerpt));
            Assert.IsNotNull(feed.Channel.TextInput);
            Assert.AreEqual(textInputTitle, feed.Channel.TextInput.Title);
            Assert.AreEqual(textInputDescription, feed.Channel.TextInput.Description);
            Assert.AreEqual(textInputName, feed.Channel.TextInput.InputName);
            Assert.AreEqual(textInputLink, feed.Channel.TextInput.Link.ToString());
            Assert.IsTrue(skipHours.SequenceEqual(feed.Channel.SkipHours.Hours.Select(x => x.Value)));
            Assert.IsTrue(skipDays.SequenceEqual(feed.Channel.SkipDays.Days.Select(x => x.Value)));
            Assert.AreEqual(1, feed.Channel.Categories.Count());
            Assert.AreEqual(categoryDomain, feed.Channel.Categories.First().Domain.ToString());
            Assert.AreEqual(categoryName, feed.Channel.Categories.First().CategoryName);
            //Assert.AreEqual(4, feed.Channel.Extensions.Count());
            //Assert.AreEqual(ext1Name, feed.Channel.Extensions.First().Name);
            //Assert.AreEqual(ext1Prefix, feed.Channel.Extensions.First().Prefix);
            //Assert.IsNotNull(feed.Channel.Extensions.First().PrimaryNamespace);
            Assert.AreEqual(25, feed.Channel.Items.Count());
            var firstItem = feed.Channel.Items.First();
            Assert.IsNotNull(firstItem);
            Assert.AreEqual(item1Title, firstItem.Title);
            Assert.AreEqual(item1Author, firstItem.Author);
            Assert.IsNotNull(firstItem.Guid);
            Assert.AreEqual(item1Guid, firstItem.Guid.Value);
            Assert.IsFalse(firstItem.Guid.IsPermaLink);
            Assert.AreEqual(item1PubDate, firstItem.PubDate);
            Assert.AreEqual(5, firstItem.Categories.Count());
            //var firstMediaContentExt = firstItem.Extensions.Where(x => x.Prefix == "media" && x.Name == "content").FirstOrDefault();
            //Assert.IsNotNull(firstMediaContentExt);
            //Assert.IsTrue(firstMediaContentExt.ToString().Contains(item1MediaContentUrl));
            var lastItem = feed.Channel.Items.Last();
            Assert.IsNotNull(lastItem);
        }
示例#5
0
        private void MakeAtomFeedAssertions(IXmlElement document)
        {
            #region Constants

            const string authorName = "David";
            const string authorUri = "http://www.blogger.com/profile/06751101786776663258";
            const string authorEmail = "*****@*****.**";
            const string cat1Term = "Blogs/News";
            const string cat1Scheme = "http://example.com/schemes/categories";
            const string cat1Label = "<Blogs & News>";
            const string contribName = "Bob Lawbla";
            const string contribUri = "http://www.blogger.com/profile/06751101786776661148";
            const string contribEmail = "*****@*****.**";
            const string genUri = "http://www.blogger.com/";
            const string genName = "Blogger";
            const string iconUri = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/PNG_transparency_demonstration_2.png/280px-PNG_transparency_demonstration_1.png";
            const string id = "tag:blogger.com,1999:blog-8677504";
            const string link1Rel = "http://schemas.google.com/g/2005#feed";
            var link1Type = "application/atom+xml";
            const string logoUri = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/PNG_transparency_demonstration_2.png/280px-PNG_transparency_demonstration_2.png";
            var feedLang = LanguageTag.Parse("en-GB");
            const string rightsBaseId = "http://example.co.uk/license";
            var rightsLang = LanguageTag.Parse("en-GB");
            var rightsType = AtomTextType.xhtml;
            //var rightsText = "\r\n    <xhtml:div xmlns:xhtml=\"http://www.w3.org/2000/xhtml\">Oy Guv&apos;na, no rights! \r\n      <xhtml:em> &lt; </xhtml:em>\r\n    </xhtml:div>";
            //var rightsTextEscaped = "\r\n    <xhtml:div xmlns:xhtml=\"http://www.w3.org/2000/xhtml\">Oy Guv&apos;na, no rights! \r\n      \r\n      <xhtml:em> &lt; </xhtml:em>\r\n    </xhtml:div>";
            
            //"<xhtml:div>Oy Guv'na, no rights! <xhtml:em> &lt; </xhtml:em></xhtml:div>";
            //"Oy, Guv'nor you ain't got NO right'a be readin' 'is!";
            const string subtitle = "Qué barbaridad!";
            var subtitleLang = LanguageTag.Parse("es-MX");
            const string title = "A Bear Librarians's Cave";
            var titleType = AtomTextType.text;
            var updated = new DateTime(2011, 6, 21, 9, 21, 56, 27); //2011-06-21T02:21:56.027-07:00
            //const string lastExtPrefix = "openSearch";
            //const string lastExtName = "itemsPerPage";
            //const string lastExtContent = ">25</";

            const string entryAuthorEmail = "*****@*****.**";
            //const string entryAuthorExtPrefix = "gd";
            //const string entryAuthorExtName = "extendedProperty";
            //const string entryAuthorExtContent = "<gd:extendedProperty xmlns:gd=\"http://schemas.google.com/g/2005\" name=\"OpenSocialUserId\" value=\"12777363245656199557\" />";
            const string entryCategoryTerm = "Comedy";
            const string entryContentText = "Ok, so here we go again.  I really like to write, but I just never seem to find the time to stay focused.  Right now I&apos;m typing this entry as one of my classes is taking a test.  I&apos;m working full-time as a librarian and teaching three classes in the evening.  It&apos;s still fun to teach, but it&apos;s also quite tiring.  I never knew how draining it was to perform like that three nights a week.  I can only imagine how it is for comedians and other performers.  I really do feel like what I do is part education and part entertainment.  I know how bored I was in school, so I like to keep my classes a bit more comical and on the entertaining side.  This is helpful, especially when teaching night classes!!&lt;br /&gt;&lt;br /&gt;Work still basically is a give and take proposition.  As I have stated before, I really like being a librarian, I just don&apos;t necessarily like where I am librarianing at! (Please pardon the grammatical diversion)  I have been interviewing for multiple jobs mainly to keep my feet wet and my intellect stimulated, but there are times I really want to stay where I am and finish the projects I&apos;ve started.  However, if I keep getting crappy emails from people at work, I&apos;m going to have to get going!  It rarely happens, and honestly this is really the first time I&apos;ve ever heard anyone complain.  However, they intimated that others were dissatisfied with the time it sometimes takes to get materials to them.  I am trying to rework the tracking of purchases at work to stay on top of things, but sometimes I have no control over timeframes.  One of the shipping departments at a specific location lost a box of five rather large books, but I didn&apos;t hear about it for 6 months.  Now I&apos;ve got someone complaining that I didn&apos;t get them some books, which I am sure that I ordered, in three weeks.  I am glad that they notified me, but they were pretty harsh with the wording.  I am doing my best with minimal support and understanding.  I mean, it&apos;s not like I&apos;m one person with two assistants trying to support the information needs of a 4000 employee company or anything.  Not to mention that I&apos;m trying to drag my portion of the information network into the 21st century all while the bloody IT department is trying to take over the company and decided who gets to do what.  For goddesses sake, they don&apos;t even have an OPAC!  I&apos;m just trying to make things better and all I get is, sorry, but your little library project isn&apos;t worthwhile, now go back and shelve some books.  I think that&apos;s the biggest problem I have.  Only a very few people respect what I do, and even fewer understand it.  The fact that I report to a pharmacist who only works part-time speaks volumes about how they value my position.  Don&apos;t get me wrong, I am happy with my salary, and I love my co-workers, but there is little or no validation of me as an employee.  No one truly seems to understand what I can do for the company, or what the library can do for that matter.&lt;br /&gt;&lt;br /&gt;That kind of shit really pisses me off, and no matter how many people I talk to, no matte how may emails I send out, and no matter how much I plan improvements, nothing seems to really matter.  Perhaps that is just the way it is at most jobs, but I can&apos;t help but feel that there is a job out there where I can feel at least moderately validated as a thinking, breathing human being.  I know that my job at the hospital back in Kansas City gave me a great sense of validation.  I was frequently asked to work on committees, and to share my knowledge and experience in new and interesting ways.  People frequently sought my insight on various problems, library-related or otherwise.  I truly felt like a valuable member of the team.  Now I just feel like a lump of flesh doing just enough to get by and get a raise every year.&lt;br /&gt;&lt;br /&gt;Thank goodness I do at least have the diversion of teaching, or I will as long as I go and get a bloody TB test this week.  My CC is nice, but the rules and attendance taking are growing a bit old.  I feel like a second grade teacher having to take roll every day.  If they don&apos;t want to come to class, it&apos;s bloody fine with me.  They are all over 18 and are paying their money.  If they think playing xbox is more important that school so be it.  I&apos;m not a bloody kindergarden teacher.  Maybe I&apos;ll quit taking roll and just start making that shit up!  Might make my gradesheets look more normal.  Hmmmmmm . . . .&lt;br /&gt;&lt;br /&gt;Ok, well enough rant for now.  Maybe my next post will be more of a rave.  I would hate for people to think that I&apos;m that negative.  I really am just a positive person having a bad day!!!!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&apos;1&apos; height=&apos;1&apos; src=&apos;https://blogger.googleusercontent.com/tracker/8677504-112778942212704032?l=bearbrarian.blogspot.com&apos; alt=&apos;&apos; /&gt;&lt;/div&gt;";
            //"Ok, so here we go again.  I really like to write, but I just never seem to find the time to stay focused.  Right now I'm typing this entry as one of my classes is taking a test.  I'm working full-time as a librarian and teaching three classes in the evening.  It's still fun to teach, but it's also quite tiring.  I never knew how draining it was to perform like that three nights a week.  I can only imagine how it is for comedians and other performers.  I really do feel like what I do is part education and part entertainment.  I know how bored I was in school, so I like to keep my classes a bit more comical and on the entertaining side.  This is helpful, especially when teaching night classes!!<br /><br />Work still basically is a give and take proposition.  As I have stated before, I really like being a librarian, I just don't necessarily like where I am librarianing at! (Please pardon the grammatical diversion)  I have been interviewing for multiple jobs mainly to keep my feet wet and my intellect stimulated, but there are times I really want to stay where I am and finish the projects I've started.  However, if I keep getting crappy emails from people at work, I'm going to have to get going!  It rarely happens, and honestly this is really the first time I've ever heard anyone complain.  However, they intimated that others were dissatisfied with the time it sometimes takes to get materials to them.  I am trying to rework the tracking of purchases at work to stay on top of things, but sometimes I have no control over timeframes.  One of the shipping departments at a specific location lost a box of five rather large books, but I didn't hear about it for 6 months.  Now I've got someone complaining that I didn't get them some books, which I am sure that I ordered, in three weeks.  I am glad that they notified me, but they were pretty harsh with the wording.  I am doing my best with minimal support and understanding.  I mean, it's not like I'm one person with two assistants trying to support the information needs of a 4000 employee company or anything.  Not to mention that I'm trying to drag my portion of the information network into the 21st century all while the bloody IT department is trying to take over the company and decided who gets to do what.  For goddesses sake, they don't even have an OPAC!  I'm just trying to make things better and all I get is, sorry, but your little library project isn't worthwhile, now go back and shelve some books.  I think that's the biggest problem I have.  Only a very few people respect what I do, and even fewer understand it.  The fact that I report to a pharmacist who only works part-time speaks volumes about how they value my position.  Don't get me wrong, I am happy with my salary, and I love my co-workers, but there is little or no validation of me as an employee.  No one truly seems to understand what I can do for the company, or what the library can do for that matter.<br /><br />That kind of shit really pisses me off, and no matter how many people I talk to, no matte how may emails I send out, and no matter how much I plan improvements, nothing seems to really matter.  Perhaps that is just the way it is at most jobs, but I can't help but feel that there is a job out there where I can feel at least moderately validated as a thinking, breathing human being.  I know that my job at the hospital back in Kansas City gave me a great sense of validation.  I was frequently asked to work on committees, and to share my knowledge and experience in new and interesting ways.  People frequently sought my insight on various problems, library-related or otherwise.  I truly felt like a valuable member of the team.  Now I just feel like a lump of flesh doing just enough to get by and get a raise every year.<br /><br />Thank goodness I do at least have the diversion of teaching, or I will as long as I go and get a bloody TB test this week.  My CC is nice, but the rules and attendance taking are growing a bit old.  I feel like a second grade teacher having to take roll every day.  If they don't want to come to class, it's bloody fine with me.  They are all over 18 and are paying their money.  If they think playing xbox is more important that school so be it.  I'm not a bloody kindergarden teacher.  Maybe I'll quit taking roll and just start making that shit up!  Might make my gradesheets look more normal.  Hmmmmmm . . . .<br /><br />Ok, well enough rant for now.  Maybe my next post will be more of a rave.  I would hate for people to think that I'm that negative.  I really am just a positive person having a bad day!!!!<div class=\"blogger-post-footer\"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8677504-112778942212704032?l=bearbrarian.blogspot.com' alt='' /></div>";
            var entryContentType = AtomTextType.html;
            const string entryContrib3Name = "Curly";
            const string entryId = "tag:blogger.com,1999:blog-8677504.post-112778942212704032";
            const string entryLink5Rel = "alternate";
            const string entryLink5Href = "http://bearbrarian.blogspot.com/2005/09/ways-down-road.html";
            var entryLink5MediaType = "text/html";
            const string entryLink5Title = "A ways down the road...";
            var entryLink5HrefLang = LanguageTag.Parse("en-US");
            var entryPublished = new DateTime(2005, 9, 27, 2, 31, 0); //2005-09-26T19:31:00.000-07:00
            const string entryRights = "You have the right to remain silent.";

            const string entrySourceTitleText = "\r\n        <b xmlns=\"http://www.w3.org/2005/Atom\">The original article</b>";
            var entrySourceTitleType = AtomTextType.html;
            const string entrySummary = "road, what road?";
            const string entryTitle = "A ways down the road";
            var entryUpdated = new DateTime(2005, 9, 27, 2, 50, 22, 140); //2005-09-26T19:50:22.140-07:00
            //var entryExtension1Prefix = "thr";
            //var entryExtension1Name = "total";

            #endregion

            var feed = document.Root as IAtomFeed;

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.Lang);

            Assert.AreEqual(feedLang.PrimaryLanguage, feed.Lang.PrimaryLanguage);
            Assert.AreEqual(feedLang.Country, feed.Lang.Country);
            Assert.AreEqual(4, feed.Namespaces.Count());
            Assert.IsNotNull(feed.Namespaces.Last());
            Assert.AreEqual(1, document.Where<IStyleSheet>(x => x != null).Count());
            Assert.IsNotNull(document.Where<IStyleSheet>(x => x != null).FirstOrDefault());

            Assert.AreEqual(1, feed.Authors.Count());
            Assert.AreEqual(authorName, feed.Authors.First().PersonName);
            Assert.AreEqual(authorUri, feed.Authors.First().Uri.ToString());
            Assert.AreEqual(authorEmail, feed.Authors.First().Email);

            Assert.AreEqual(2, feed.Categories.Count());
            Assert.IsNotNull(feed.Categories.First());
            Assert.AreEqual(cat1Term, feed.Categories.First().Term);
            Assert.AreEqual(cat1Scheme, feed.Categories.First().Scheme.ToString());
            Assert.AreEqual(cat1Label, feed.Categories.First().Label);

            Assert.AreEqual(2, feed.Contributors.Count());
            Assert.AreEqual(contribName, feed.Contributors.First().PersonName);
            Assert.AreEqual(contribUri, feed.Contributors.First().Uri.ToString());
            Assert.AreEqual(contribEmail, feed.Contributors.First().Email);

            Assert.IsNotNull(feed.Generator);
            Assert.AreEqual(genUri, feed.Generator.Uri.ToString());
            Assert.AreEqual(genName, feed.Generator.GeneratorName);

            Assert.IsNotNull(feed.Icon);
            Assert.AreEqual(iconUri, feed.Icon.Uri.ToString());

            Assert.IsNotNull(feed.Id);
            Assert.AreEqual(id, feed.Id.Content.ToString());

            Assert.AreEqual(4, feed.Links.Count());
            Assert.AreEqual(link1Rel, feed.Links.First().Rel);
            Assert.AreEqual(link1Type, feed.Links.First().MediaType);

            Assert.IsNotNull(feed.Logo);
            Assert.AreEqual(logoUri, feed.Logo.Uri.ToString());

            Assert.IsNotNull(feed.Rights);
            Assert.AreEqual(rightsBaseId, feed.Rights.BaseId.ToString());
            Assert.AreEqual(rightsLang, feed.Rights.Lang);
            Assert.AreEqual(rightsType, feed.Rights.Type);
            //Assert.AreEqual(rightsText, feed.Rights.Text);            

            Assert.IsNotNull(feed.Subtitle);
            Assert.AreEqual(subtitle, feed.Subtitle.Text);
            Assert.AreEqual(subtitleLang, feed.Subtitle.Lang);

            Assert.IsNotNull(feed.Title);
            Assert.AreEqual(title, feed.Title.Text);
            Assert.AreEqual(titleType, feed.Title.Type);

            Assert.IsNotNull(feed.Updated);
            Assert.AreEqual(updated, feed.Updated.Date);

            //Assert.AreEqual(3, feed.Extensions.Count());
            //Assert.AreEqual(lastExtPrefix, feed.Extensions.Last().Prefix);
            //Assert.AreEqual(lastExtName, feed.Extensions.Last().Name);
            //Assert.IsTrue(feed.Extensions.Last().ToString().Contains(lastExtContent));

            Assert.AreEqual(6, feed.Entries.Count());
            Assert.IsNotNull(feed.Entries.First());

            Assert.AreEqual(1, feed.Entries.First().Authors.Count());
            Assert.AreEqual(entryAuthorEmail, feed.Entries.First().Authors.First().Email);
            //Assert.AreEqual(1, feed.Entries.First().Authors.First().Extensions.Count());
            //Assert.AreEqual(entryAuthorExtPrefix, feed.Entries.First().Authors.First().Extensions.First().Prefix);
            //Assert.AreEqual(entryAuthorExtName, feed.Entries.First().Authors.First().Extensions.First().Name);
            //Assert.AreEqual(entryAuthorExtContent, feed.Entries.First().Authors.First().Extensions.First().ToString());

            Assert.AreEqual(1, feed.Entries.First().Categories.Count());
            Assert.AreEqual(entryCategoryTerm, feed.Entries.First().Categories.First().Term);

            Assert.IsNotNull(feed.Entries.First().Content);
            Assert.AreEqual(entryContentText, feed.Entries.First().Content.Text);
            Assert.AreEqual(entryContentType, feed.Entries.First().Content.Type);

            Assert.AreEqual(3, feed.Entries.First().Contributors.Count());
            Assert.AreEqual(entryContrib3Name, feed.Entries.First().Contributors.Last().PersonName);

            Assert.IsNotNull(feed.Entries.First().Id);
            Assert.AreEqual(entryId, feed.Entries.First().Id.Content.ToString());

            Assert.AreEqual(5, feed.Entries.First().Links.Count());
            Assert.AreEqual(entryLink5Href, feed.Entries.First().Links.Last().Href.ToString());
            Assert.AreEqual(entryLink5HrefLang, feed.Entries.First().Links.Last().HrefLang);
            Assert.AreEqual(entryLink5MediaType, feed.Entries.First().Links.Last().MediaType);
            Assert.AreEqual(entryLink5Title, feed.Entries.First().Links.Last().Title);
            Assert.AreEqual(entryLink5Rel, feed.Entries.First().Links.Last().Rel);

            Assert.IsNotNull(feed.Entries.First().Published);
            Assert.AreEqual(entryPublished, feed.Entries.First().Published.Date);

            Assert.IsNotNull(feed.Entries.First().Rights);
            Assert.AreEqual(entryRights, feed.Entries.First().Rights.Text);

            Assert.IsNotNull(feed.Entries.First().Source);
            Assert.IsNotNull(feed.Entries.First().Source.Title);
            Assert.AreEqual(entrySourceTitleText, feed.Entries.First().Source.Title.Text);
            Assert.AreEqual(entrySourceTitleType, feed.Entries.First().Source.Title.Type);

            Assert.IsNotNull(feed.Entries.First().Summary);
            Assert.AreEqual(entrySummary, feed.Entries.First().Summary.Text);

            Assert.IsNotNull(feed.Entries.First().Title);
            Assert.AreEqual(entryTitle, feed.Entries.First().Title.Text);

            Assert.IsNotNull(feed.Entries.First().Updated);
            Assert.AreEqual(entryUpdated, feed.Entries.First().Updated.Date);

            //Assert.AreEqual(1, feed.Entries.First().Extensions.Count());
            //Assert.AreEqual(entryExtension1Prefix, feed.Entries.First().Extensions.First().Prefix);
            //Assert.AreEqual(entryExtension1Name, feed.Entries.First().Extensions.First().Name);
        }
示例#6
0
        private void MakeAtomXmlAssertions(IXmlElement xml)
        {
            const string atomNamespace = "http://www.w3.org/2005/Atom";
            const string openSearchNamespace = "http://a9.com/-/spec/opensearchrss/1.0/";

            Assert.IsNotNull(xml);
            var feed = xml.Where<IElement>(x => x.Name.LocalPart == "feed").FirstOrDefault();
            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.CurrentNamespace);
            Assert.AreEqual(atomNamespace, feed.CurrentNamespace.Identifier.ToString());
            var totalResults = feed.Where<IOpenSearchTotalResults>(x => true);
            Assert.AreEqual(2, totalResults.Count());
            Assert.IsTrue(totalResults.All(x => x.CurrentNamespace != null && x.CurrentNamespace.Identifier.ToString() == openSearchNamespace && x.Content > 0));
        }
示例#7
0
        private void MakeAtomFeedAssertions(IXmlElement document)
        {
            #region Constants

            const string authorName   = "David";
            const string authorUri    = "http://www.blogger.com/profile/06751101786776663258";
            const string authorEmail  = "*****@*****.**";
            const string cat1Term     = "Blogs/News";
            const string cat1Scheme   = "http://example.com/schemes/categories";
            const string cat1Label    = "<Blogs & News>";
            const string contribName  = "Bob Lawbla";
            const string contribUri   = "http://www.blogger.com/profile/06751101786776661148";
            const string contribEmail = "*****@*****.**";
            const string genUri       = "http://www.blogger.com/";
            const string genName      = "Blogger";
            const string iconUri      = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/PNG_transparency_demonstration_2.png/280px-PNG_transparency_demonstration_1.png";
            const string id           = "tag:blogger.com,1999:blog-8677504";
            const string link1Rel     = "http://schemas.google.com/g/2005#feed";
            var          link1Type    = "application/atom+xml";
            const string logoUri      = "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/PNG_transparency_demonstration_2.png/280px-PNG_transparency_demonstration_2.png";
            var          feedLang     = LanguageTag.Parse("en-GB");
            const string rightsBaseId = "http://example.co.uk/license";
            var          rightsLang   = LanguageTag.Parse("en-GB");
            var          rightsType   = AtomTextType.xhtml;
            //var rightsText = "\r\n    <xhtml:div xmlns:xhtml=\"http://www.w3.org/2000/xhtml\">Oy Guv&apos;na, no rights! \r\n      <xhtml:em> &lt; </xhtml:em>\r\n    </xhtml:div>";
            //var rightsTextEscaped = "\r\n    <xhtml:div xmlns:xhtml=\"http://www.w3.org/2000/xhtml\">Oy Guv&apos;na, no rights! \r\n      \r\n      <xhtml:em> &lt; </xhtml:em>\r\n    </xhtml:div>";

            //"<xhtml:div>Oy Guv'na, no rights! <xhtml:em> &lt; </xhtml:em></xhtml:div>";
            //"Oy, Guv'nor you ain't got NO right'a be readin' 'is!";
            const string subtitle     = "Qué barbaridad!";
            var          subtitleLang = LanguageTag.Parse("es-MX");
            const string title        = "A Bear Librarians's Cave";
            var          titleType    = AtomTextType.text;
            var          updated      = new DateTime(2011, 6, 21, 9, 21, 56, 27); //2011-06-21T02:21:56.027-07:00
            //const string lastExtPrefix = "openSearch";
            //const string lastExtName = "itemsPerPage";
            //const string lastExtContent = ">25</";

            const string entryAuthorEmail = "*****@*****.**";
            //const string entryAuthorExtPrefix = "gd";
            //const string entryAuthorExtName = "extendedProperty";
            //const string entryAuthorExtContent = "<gd:extendedProperty xmlns:gd=\"http://schemas.google.com/g/2005\" name=\"OpenSocialUserId\" value=\"12777363245656199557\" />";
            const string entryCategoryTerm = "Comedy";
            const string entryContentText  = "Ok, so here we go again.  I really like to write, but I just never seem to find the time to stay focused.  Right now I&apos;m typing this entry as one of my classes is taking a test.  I&apos;m working full-time as a librarian and teaching three classes in the evening.  It&apos;s still fun to teach, but it&apos;s also quite tiring.  I never knew how draining it was to perform like that three nights a week.  I can only imagine how it is for comedians and other performers.  I really do feel like what I do is part education and part entertainment.  I know how bored I was in school, so I like to keep my classes a bit more comical and on the entertaining side.  This is helpful, especially when teaching night classes!!&lt;br /&gt;&lt;br /&gt;Work still basically is a give and take proposition.  As I have stated before, I really like being a librarian, I just don&apos;t necessarily like where I am librarianing at! (Please pardon the grammatical diversion)  I have been interviewing for multiple jobs mainly to keep my feet wet and my intellect stimulated, but there are times I really want to stay where I am and finish the projects I&apos;ve started.  However, if I keep getting crappy emails from people at work, I&apos;m going to have to get going!  It rarely happens, and honestly this is really the first time I&apos;ve ever heard anyone complain.  However, they intimated that others were dissatisfied with the time it sometimes takes to get materials to them.  I am trying to rework the tracking of purchases at work to stay on top of things, but sometimes I have no control over timeframes.  One of the shipping departments at a specific location lost a box of five rather large books, but I didn&apos;t hear about it for 6 months.  Now I&apos;ve got someone complaining that I didn&apos;t get them some books, which I am sure that I ordered, in three weeks.  I am glad that they notified me, but they were pretty harsh with the wording.  I am doing my best with minimal support and understanding.  I mean, it&apos;s not like I&apos;m one person with two assistants trying to support the information needs of a 4000 employee company or anything.  Not to mention that I&apos;m trying to drag my portion of the information network into the 21st century all while the bloody IT department is trying to take over the company and decided who gets to do what.  For goddesses sake, they don&apos;t even have an OPAC!  I&apos;m just trying to make things better and all I get is, sorry, but your little library project isn&apos;t worthwhile, now go back and shelve some books.  I think that&apos;s the biggest problem I have.  Only a very few people respect what I do, and even fewer understand it.  The fact that I report to a pharmacist who only works part-time speaks volumes about how they value my position.  Don&apos;t get me wrong, I am happy with my salary, and I love my co-workers, but there is little or no validation of me as an employee.  No one truly seems to understand what I can do for the company, or what the library can do for that matter.&lt;br /&gt;&lt;br /&gt;That kind of shit really pisses me off, and no matter how many people I talk to, no matte how may emails I send out, and no matter how much I plan improvements, nothing seems to really matter.  Perhaps that is just the way it is at most jobs, but I can&apos;t help but feel that there is a job out there where I can feel at least moderately validated as a thinking, breathing human being.  I know that my job at the hospital back in Kansas City gave me a great sense of validation.  I was frequently asked to work on committees, and to share my knowledge and experience in new and interesting ways.  People frequently sought my insight on various problems, library-related or otherwise.  I truly felt like a valuable member of the team.  Now I just feel like a lump of flesh doing just enough to get by and get a raise every year.&lt;br /&gt;&lt;br /&gt;Thank goodness I do at least have the diversion of teaching, or I will as long as I go and get a bloody TB test this week.  My CC is nice, but the rules and attendance taking are growing a bit old.  I feel like a second grade teacher having to take roll every day.  If they don&apos;t want to come to class, it&apos;s bloody fine with me.  They are all over 18 and are paying their money.  If they think playing xbox is more important that school so be it.  I&apos;m not a bloody kindergarden teacher.  Maybe I&apos;ll quit taking roll and just start making that shit up!  Might make my gradesheets look more normal.  Hmmmmmm . . . .&lt;br /&gt;&lt;br /&gt;Ok, well enough rant for now.  Maybe my next post will be more of a rave.  I would hate for people to think that I&apos;m that negative.  I really am just a positive person having a bad day!!!!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&apos;1&apos; height=&apos;1&apos; src=&apos;https://blogger.googleusercontent.com/tracker/8677504-112778942212704032?l=bearbrarian.blogspot.com&apos; alt=&apos;&apos; /&gt;&lt;/div&gt;";
            //"Ok, so here we go again.  I really like to write, but I just never seem to find the time to stay focused.  Right now I'm typing this entry as one of my classes is taking a test.  I'm working full-time as a librarian and teaching three classes in the evening.  It's still fun to teach, but it's also quite tiring.  I never knew how draining it was to perform like that three nights a week.  I can only imagine how it is for comedians and other performers.  I really do feel like what I do is part education and part entertainment.  I know how bored I was in school, so I like to keep my classes a bit more comical and on the entertaining side.  This is helpful, especially when teaching night classes!!<br /><br />Work still basically is a give and take proposition.  As I have stated before, I really like being a librarian, I just don't necessarily like where I am librarianing at! (Please pardon the grammatical diversion)  I have been interviewing for multiple jobs mainly to keep my feet wet and my intellect stimulated, but there are times I really want to stay where I am and finish the projects I've started.  However, if I keep getting crappy emails from people at work, I'm going to have to get going!  It rarely happens, and honestly this is really the first time I've ever heard anyone complain.  However, they intimated that others were dissatisfied with the time it sometimes takes to get materials to them.  I am trying to rework the tracking of purchases at work to stay on top of things, but sometimes I have no control over timeframes.  One of the shipping departments at a specific location lost a box of five rather large books, but I didn't hear about it for 6 months.  Now I've got someone complaining that I didn't get them some books, which I am sure that I ordered, in three weeks.  I am glad that they notified me, but they were pretty harsh with the wording.  I am doing my best with minimal support and understanding.  I mean, it's not like I'm one person with two assistants trying to support the information needs of a 4000 employee company or anything.  Not to mention that I'm trying to drag my portion of the information network into the 21st century all while the bloody IT department is trying to take over the company and decided who gets to do what.  For goddesses sake, they don't even have an OPAC!  I'm just trying to make things better and all I get is, sorry, but your little library project isn't worthwhile, now go back and shelve some books.  I think that's the biggest problem I have.  Only a very few people respect what I do, and even fewer understand it.  The fact that I report to a pharmacist who only works part-time speaks volumes about how they value my position.  Don't get me wrong, I am happy with my salary, and I love my co-workers, but there is little or no validation of me as an employee.  No one truly seems to understand what I can do for the company, or what the library can do for that matter.<br /><br />That kind of shit really pisses me off, and no matter how many people I talk to, no matte how may emails I send out, and no matter how much I plan improvements, nothing seems to really matter.  Perhaps that is just the way it is at most jobs, but I can't help but feel that there is a job out there where I can feel at least moderately validated as a thinking, breathing human being.  I know that my job at the hospital back in Kansas City gave me a great sense of validation.  I was frequently asked to work on committees, and to share my knowledge and experience in new and interesting ways.  People frequently sought my insight on various problems, library-related or otherwise.  I truly felt like a valuable member of the team.  Now I just feel like a lump of flesh doing just enough to get by and get a raise every year.<br /><br />Thank goodness I do at least have the diversion of teaching, or I will as long as I go and get a bloody TB test this week.  My CC is nice, but the rules and attendance taking are growing a bit old.  I feel like a second grade teacher having to take roll every day.  If they don't want to come to class, it's bloody fine with me.  They are all over 18 and are paying their money.  If they think playing xbox is more important that school so be it.  I'm not a bloody kindergarden teacher.  Maybe I'll quit taking roll and just start making that shit up!  Might make my gradesheets look more normal.  Hmmmmmm . . . .<br /><br />Ok, well enough rant for now.  Maybe my next post will be more of a rave.  I would hate for people to think that I'm that negative.  I really am just a positive person having a bad day!!!!<div class=\"blogger-post-footer\"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8677504-112778942212704032?l=bearbrarian.blogspot.com' alt='' /></div>";
            var          entryContentType    = AtomTextType.html;
            const string entryContrib3Name   = "Curly";
            const string entryId             = "tag:blogger.com,1999:blog-8677504.post-112778942212704032";
            const string entryLink5Rel       = "alternate";
            const string entryLink5Href      = "http://bearbrarian.blogspot.com/2005/09/ways-down-road.html";
            var          entryLink5MediaType = "text/html";
            const string entryLink5Title     = "A ways down the road...";
            var          entryLink5HrefLang  = LanguageTag.Parse("en-US");
            var          entryPublished      = new DateTime(2005, 9, 27, 2, 31, 0); //2005-09-26T19:31:00.000-07:00
            const string entryRights         = "You have the right to remain silent.";

            const string entrySourceTitleText = "\r\n        <b xmlns=\"http://www.w3.org/2005/Atom\">The original article</b>";
            var          entrySourceTitleType = AtomTextType.html;
            const string entrySummary         = "road, what road?";
            const string entryTitle           = "A ways down the road";
            var          entryUpdated         = new DateTime(2005, 9, 27, 2, 50, 22, 140); //2005-09-26T19:50:22.140-07:00
            //var entryExtension1Prefix = "thr";
            //var entryExtension1Name = "total";

            #endregion

            var feed = document.Root as IAtomFeed;

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.Lang);

            Assert.AreEqual(feedLang.PrimaryLanguage, feed.Lang.PrimaryLanguage);
            Assert.AreEqual(feedLang.Country, feed.Lang.Country);
            Assert.AreEqual(4, feed.Namespaces.Count());
            Assert.IsNotNull(feed.Namespaces.Last());
            Assert.AreEqual(1, document.Where <IStyleSheet>(x => x != null).Count());
            Assert.IsNotNull(document.Where <IStyleSheet>(x => x != null).FirstOrDefault());

            Assert.AreEqual(1, feed.Authors.Count());
            Assert.AreEqual(authorName, feed.Authors.First().PersonName);
            Assert.AreEqual(authorUri, feed.Authors.First().Uri.ToString());
            Assert.AreEqual(authorEmail, feed.Authors.First().Email);

            Assert.AreEqual(2, feed.Categories.Count());
            Assert.IsNotNull(feed.Categories.First());
            Assert.AreEqual(cat1Term, feed.Categories.First().Term);
            Assert.AreEqual(cat1Scheme, feed.Categories.First().Scheme.ToString());
            Assert.AreEqual(cat1Label, feed.Categories.First().Label);

            Assert.AreEqual(2, feed.Contributors.Count());
            Assert.AreEqual(contribName, feed.Contributors.First().PersonName);
            Assert.AreEqual(contribUri, feed.Contributors.First().Uri.ToString());
            Assert.AreEqual(contribEmail, feed.Contributors.First().Email);

            Assert.IsNotNull(feed.Generator);
            Assert.AreEqual(genUri, feed.Generator.Uri.ToString());
            Assert.AreEqual(genName, feed.Generator.GeneratorName);

            Assert.IsNotNull(feed.Icon);
            Assert.AreEqual(iconUri, feed.Icon.Uri.ToString());

            Assert.IsNotNull(feed.Id);
            Assert.AreEqual(id, feed.Id.Content.ToString());

            Assert.AreEqual(4, feed.Links.Count());
            Assert.AreEqual(link1Rel, feed.Links.First().Rel);
            Assert.AreEqual(link1Type, feed.Links.First().MediaType);

            Assert.IsNotNull(feed.Logo);
            Assert.AreEqual(logoUri, feed.Logo.Uri.ToString());

            Assert.IsNotNull(feed.Rights);
            Assert.AreEqual(rightsBaseId, feed.Rights.BaseId.ToString());
            Assert.AreEqual(rightsLang, feed.Rights.Lang);
            Assert.AreEqual(rightsType, feed.Rights.Type);
            //Assert.AreEqual(rightsText, feed.Rights.Text);

            Assert.IsNotNull(feed.Subtitle);
            Assert.AreEqual(subtitle, feed.Subtitle.Text);
            Assert.AreEqual(subtitleLang, feed.Subtitle.Lang);

            Assert.IsNotNull(feed.Title);
            Assert.AreEqual(title, feed.Title.Text);
            Assert.AreEqual(titleType, feed.Title.Type);

            Assert.IsNotNull(feed.Updated);
            Assert.AreEqual(updated, feed.Updated.Date);

            //Assert.AreEqual(3, feed.Extensions.Count());
            //Assert.AreEqual(lastExtPrefix, feed.Extensions.Last().Prefix);
            //Assert.AreEqual(lastExtName, feed.Extensions.Last().Name);
            //Assert.IsTrue(feed.Extensions.Last().ToString().Contains(lastExtContent));

            Assert.AreEqual(6, feed.Entries.Count());
            Assert.IsNotNull(feed.Entries.First());

            Assert.AreEqual(1, feed.Entries.First().Authors.Count());
            Assert.AreEqual(entryAuthorEmail, feed.Entries.First().Authors.First().Email);
            //Assert.AreEqual(1, feed.Entries.First().Authors.First().Extensions.Count());
            //Assert.AreEqual(entryAuthorExtPrefix, feed.Entries.First().Authors.First().Extensions.First().Prefix);
            //Assert.AreEqual(entryAuthorExtName, feed.Entries.First().Authors.First().Extensions.First().Name);
            //Assert.AreEqual(entryAuthorExtContent, feed.Entries.First().Authors.First().Extensions.First().ToString());

            Assert.AreEqual(1, feed.Entries.First().Categories.Count());
            Assert.AreEqual(entryCategoryTerm, feed.Entries.First().Categories.First().Term);

            Assert.IsNotNull(feed.Entries.First().Content);
            Assert.AreEqual(entryContentText, feed.Entries.First().Content.Text);
            Assert.AreEqual(entryContentType, feed.Entries.First().Content.Type);

            Assert.AreEqual(3, feed.Entries.First().Contributors.Count());
            Assert.AreEqual(entryContrib3Name, feed.Entries.First().Contributors.Last().PersonName);

            Assert.IsNotNull(feed.Entries.First().Id);
            Assert.AreEqual(entryId, feed.Entries.First().Id.Content.ToString());

            Assert.AreEqual(5, feed.Entries.First().Links.Count());
            Assert.AreEqual(entryLink5Href, feed.Entries.First().Links.Last().Href.ToString());
            Assert.AreEqual(entryLink5HrefLang, feed.Entries.First().Links.Last().HrefLang);
            Assert.AreEqual(entryLink5MediaType, feed.Entries.First().Links.Last().MediaType);
            Assert.AreEqual(entryLink5Title, feed.Entries.First().Links.Last().Title);
            Assert.AreEqual(entryLink5Rel, feed.Entries.First().Links.Last().Rel);

            Assert.IsNotNull(feed.Entries.First().Published);
            Assert.AreEqual(entryPublished, feed.Entries.First().Published.Date);

            Assert.IsNotNull(feed.Entries.First().Rights);
            Assert.AreEqual(entryRights, feed.Entries.First().Rights.Text);

            Assert.IsNotNull(feed.Entries.First().Source);
            Assert.IsNotNull(feed.Entries.First().Source.Title);
            Assert.AreEqual(entrySourceTitleText, feed.Entries.First().Source.Title.Text);
            Assert.AreEqual(entrySourceTitleType, feed.Entries.First().Source.Title.Type);

            Assert.IsNotNull(feed.Entries.First().Summary);
            Assert.AreEqual(entrySummary, feed.Entries.First().Summary.Text);

            Assert.IsNotNull(feed.Entries.First().Title);
            Assert.AreEqual(entryTitle, feed.Entries.First().Title.Text);

            Assert.IsNotNull(feed.Entries.First().Updated);
            Assert.AreEqual(entryUpdated, feed.Entries.First().Updated.Date);

            //Assert.AreEqual(1, feed.Entries.First().Extensions.Count());
            //Assert.AreEqual(entryExtension1Prefix, feed.Entries.First().Extensions.First().Prefix);
            //Assert.AreEqual(entryExtension1Name, feed.Entries.First().Extensions.First().Name);
        }
示例#8
0
        private void MakeRssFeedAssertions(IXmlElement document)
        {
            #region Constants

            const string version        = "2.0";
            const string title          = "Ars Technica";
            const string link           = "http://arstechnica.com/index.php";
            const string description    = "The Art of Technology";
            var          language       = LanguageTag.Parse("en");
            var          lastBuildDate  = new DateTime(2011, 6, 29, 18, 45, 05); //Wed, 29 Jun 2011 18:45:05 +0000
            const string generator      = "http://www.sixapart.com/movabletype/";
            const string docs           = "http://www.rssboard.org/rss-specification";
            const string copyright      = "Copyright 2011 Conde Nast Digital. The contents of this feed are available for non-commercial use only.";
            var          pubDate        = new DateTime(2011, 6, 4, 9, 14, 58); //Sat, 4 Jun 2011 09:14:58 +0000
            const string managingEditor = "[email protected] (Ken Fisher)";
            const string webMaster      = "[email protected] (Clint Ecker)";

            const string categoryDomain = "http://www.sixapart.com/ns/types#category";
            const string categoryName   = "News";

            const string cloudDomain   = "radio.xmlstoragesystem.com";
            const int    cloudPort     = 80;
            const string cloudPath     = "/RPC2";
            const string cloudProc     = "xmlStorageSystem.rssPleaseNotify";
            var          cloudProcotol = RssCloudProtocol.xml_rpc;

            const int ttl = 45;

            const string imageUrl         = "http://static.arstechnica.net//public/v6/styles/light/images/masthead/logo.png?1309476728";
            const string imageTitle       = "Ars Technica";
            const string imageLink        = "http://arstechnica.com/index.php";
            const int    imageHeight      = 169;
            const int    imageWidth       = 300;
            const string imageDescription = "The Art of Technology";

            const string ratingExcerpt = "'http://www.gcf.org/v2.5' labels";

            const string textInputTitle       = "Contact Us";
            const string textInputDescription = "Email us with feedback";
            const string textInputName        = "Submit";
            const string textInputLink        = "http://arstechnica.com/contact-us.php";

            var skipHours = new List <Hour> {
                Hour.Zero, Hour.One, Hour.Two, Hour.Twelve, Hour.Thirteen, Hour.Nineteen, Hour.TwentyThree
            };
            var skipDays = new List <Day> {
                Day.Sunday, Day.Thursday, Day.Saturday
            };

            //const string ext1Prefix = "dc";
            //const string ext1Name = "title";
            //const string ext1Namespace = "http://purl.org/dc/elements/1.1/";

            const string item1Title  = "Impressions from Uncharted 3: Drake's Deception's open beta ";
            const string item1Author = "[email protected] (Josh McIllwain)";
            //const string item1MediaContentUrl = "http://static.arstechnica.net/assets/2011/06/uncharted-3-thumb-300x169-23017-f.jpg";
            const string item1Guid    = "http://arstechnica.com/gaming/news/2011/06/impressions-from-uncharted-3-drakes-deceptions-open-beta.ars?utm_source=rss&utm_medium=rss&utm_campaign=rss";
            var          item1PubDate = new DateTime(2011, 6, 29, 16, 47, 00); //Wed, 29 Jun 2011 11:47:00 -0500

            #endregion

            var feed = document.Root as IRssFeed;

            Assert.IsNotNull(feed);
            Assert.IsNotNull(feed.Channel);
            Assert.AreEqual(version, feed.Version);
            Assert.AreEqual(2, document.Where <IStyleSheet>(x => x != null).Count());
            Assert.AreEqual(3, feed.Namespaces.Count());

            Assert.AreEqual(title, feed.Channel.Title);
            Assert.AreEqual(link, feed.Channel.Link.ToString());
            Assert.AreEqual(description, feed.Channel.Description);
            Assert.AreEqual(language.PrimaryLanguage, feed.Channel.Language.PrimaryLanguage);
            Assert.AreEqual(lastBuildDate, feed.Channel.LastBuildDate);
            Assert.AreEqual(generator, feed.Channel.Generator);
            Assert.AreEqual(docs, feed.Channel.Docs.ToString());
            Assert.AreEqual(copyright, feed.Channel.Copyright);
            Assert.AreEqual(pubDate, feed.Channel.PubDate);
            Assert.AreEqual(managingEditor, feed.Channel.ManagingEditor);
            Assert.AreEqual(webMaster, feed.Channel.WebMaster);
            Assert.IsNotNull(feed.Channel.Cloud);
            Assert.AreEqual(cloudDomain, feed.Channel.Cloud.Domain);
            Assert.AreEqual(cloudPort, feed.Channel.Cloud.Port);
            Assert.AreEqual(cloudPath, feed.Channel.Cloud.Path);
            Assert.AreEqual(cloudProc, feed.Channel.Cloud.RegisterProcedure);
            Assert.AreEqual(cloudProcotol, feed.Channel.Cloud.Protocol);
            Assert.AreEqual(ttl, feed.Channel.Ttl.TotalMinutes);
            Assert.IsNotNull(feed.Channel.Image);
            Assert.AreEqual(imageUrl, feed.Channel.Image.Url.ToString());
            Assert.AreEqual(imageTitle, feed.Channel.Image.Title);
            Assert.AreEqual(imageLink, feed.Channel.Image.Link.ToString());
            Assert.AreEqual(imageHeight, feed.Channel.Image.Height);
            Assert.AreEqual(imageWidth, feed.Channel.Image.Width);
            Assert.AreEqual(imageDescription, feed.Channel.Image.Description);
            Assert.IsNotNull(feed.Channel.Rating);
            Assert.IsTrue(feed.Channel.Rating.Contains(ratingExcerpt));
            Assert.IsNotNull(feed.Channel.TextInput);
            Assert.AreEqual(textInputTitle, feed.Channel.TextInput.Title);
            Assert.AreEqual(textInputDescription, feed.Channel.TextInput.Description);
            Assert.AreEqual(textInputName, feed.Channel.TextInput.InputName);
            Assert.AreEqual(textInputLink, feed.Channel.TextInput.Link.ToString());
            Assert.IsTrue(skipHours.SequenceEqual(feed.Channel.SkipHours.Hours.Select(x => x.Value)));
            Assert.IsTrue(skipDays.SequenceEqual(feed.Channel.SkipDays.Days.Select(x => x.Value)));
            Assert.AreEqual(1, feed.Channel.Categories.Count());
            Assert.AreEqual(categoryDomain, feed.Channel.Categories.First().Domain.ToString());
            Assert.AreEqual(categoryName, feed.Channel.Categories.First().CategoryName);
            //Assert.AreEqual(4, feed.Channel.Extensions.Count());
            //Assert.AreEqual(ext1Name, feed.Channel.Extensions.First().Name);
            //Assert.AreEqual(ext1Prefix, feed.Channel.Extensions.First().Prefix);
            //Assert.IsNotNull(feed.Channel.Extensions.First().PrimaryNamespace);
            Assert.AreEqual(25, feed.Channel.Items.Count());
            var firstItem = feed.Channel.Items.First();
            Assert.IsNotNull(firstItem);
            Assert.AreEqual(item1Title, firstItem.Title);
            Assert.AreEqual(item1Author, firstItem.Author);
            Assert.IsNotNull(firstItem.Guid);
            Assert.AreEqual(item1Guid, firstItem.Guid.Value);
            Assert.IsFalse(firstItem.Guid.IsPermaLink);
            Assert.AreEqual(item1PubDate, firstItem.PubDate);
            Assert.AreEqual(5, firstItem.Categories.Count());
            //var firstMediaContentExt = firstItem.Extensions.Where(x => x.Prefix == "media" && x.Name == "content").FirstOrDefault();
            //Assert.IsNotNull(firstMediaContentExt);
            //Assert.IsTrue(firstMediaContentExt.ToString().Contains(item1MediaContentUrl));
            var lastItem = feed.Channel.Items.Last();
            Assert.IsNotNull(lastItem);
        }