public void VerifyGetEntry() { Entry entry; IPrincipal originalPrincipal; entry = BlogDataService.GetEntry( "0c805dc8-e389-4d05-9bd8-9a99a28d78f4"); Assert.AreEqual("Interesting but not necessarily true.", entry.Title); // Don't return private entries by default. entry = BlogDataService.GetEntry( "40f5dbc6-3a50-4bea-833b-8be993886258"); Assert.IsNull(entry, "Unexpectedly we retrieved a private entry."); originalPrincipal = Thread.CurrentPrincipal; // Return private entries if requested explicitly. Thread.CurrentPrincipal = new GenericPrincipal( new GenericIdentity("junk", "junk"), new string[] { "admin" }); entry = BlogDataService.GetEntry( "40f5dbc6-3a50-4bea-833b-8be993886258"); Assert.AreEqual("Compatible Transitional Capability (CTC)", entry.Title); Thread.CurrentPrincipal = originalPrincipal; // Don't return private entries by default. entry = BlogDataService.GetEntry( "40f5dbc6-3a50-4bea-833b-8be993886258"); Assert.IsNull(entry, "Unexpectedly we retrieved a private entry."); }
public void VerifyContains() { Entry entry1, entry2; entry1 = BlogDataService.GetEntry("ebd3060-b3b0-4ab1-baea-cd12ae34a575"); EntryCollection entries = new EntryCollection(); entries.Add(entry1); Assert.IsTrue(entries.Contains(entry1), "Unexpectedly the entry did not exist."); entry2 = BlogDataService.GetEntry("ebd3060-b3b0-4ab1-baea-cd12ae34a575"); // The entries returned are identical (ReferenceEquals) Assert.AreSame(entry1, entry2, "Unexpectedly and entirely different entry instance was returned."); Assert.IsTrue(entries.Contains(entry2), "Unexpectedly the entry did not exist."); }
public void VerifySaveEntry() { Guid entryId = Guid.NewGuid(); Entry entry = new Entry(); entry.Initialize(); entry.CreatedUtc = new DateTime(2004, 1, 1); entry.Title = "Happy New ear"; entry.Content = "The beginning of a new year."; entry.Categories = "Test"; entry.EntryId = entryId.ToString(); entry.Description = "The description of the entry."; entry.Author = "Inigo Montoya"; // TODO: Update so private entries will work as well. entry.IsPublic = true; entry.Language = "C#"; entry.Link = "http://mark.michaelis.net/blog"; entry.ModifiedUtc = entry.CreatedUtc; entry.ShowOnFrontPage = false; BlogDataService.SaveEntry(entry); entry = BlogDataService.GetEntry(entryId.ToString()); Assert.IsNotNull(entry, "Unable to retrieve the specified entry."); Assert.AreEqual(entryId.ToString(), entry.EntryId); Assert.AreEqual(new DateTime(2004, 1, 1), entry.CreatedUtc); Assert.AreEqual("Happy New ear", entry.Title); Assert.AreEqual("The beginning of a new year.", entry.Content); Assert.AreEqual("Test", entry.Categories); Assert.AreEqual("The description of the entry.", entry.Description); Assert.AreEqual("Inigo Montoya", entry.Author); Assert.AreEqual(true, entry.IsPublic); Assert.AreEqual("C#", entry.Language); Assert.AreEqual("http://mark.michaelis.net/blog", entry.Link); Assert.AreEqual(entry.CreatedUtc, entry.ModifiedUtc); Assert.AreEqual(false, entry.ShowOnFrontPage); }