public void MergesAllFullComments() { EntryPage target = TestingShared.GenerateEntryPage(); EntryPage source = TestingShared.GenerateEntryPage(true); Comment[] commentsBefore = _rh.EnumerateAll(target.Replies) .ToArray(); _rh.MergeFrom(target, source); Comment[] commentsAfter = _rh.EnumerateAll(target.Replies) .ToArray(); // No objects replaced. for (int i = 0; i < commentsBefore.Length; i++) { Assert.AreSame(commentsBefore[i], commentsAfter[i]); Assert.IsTrue( commentsAfter[i] .IsFull ); Assert.IsTrue( !string.IsNullOrWhiteSpace( commentsAfter[i] .Text ) ); } }
public void EnsuresTargetCommentsPagesDataIsNull(bool startFromEmpty) { EntryPage target = startFromEmpty ? new EntryPage() : TestingShared.GenerateEntryPage(); EntryPage source = TestingShared.GenerateEntryPage(true); _eph.AddData(target, source); Assert.IsTrue(CommentPages.IsEmpty(target.CommentPages)); }
public void ThrowsIfTargetAndSourceHaveDifferentIds() { Entry e1 = new Entry(); Entry e2 = TestingShared.GenerateEntryPage() .Entry; e1.Id = 1; e2.Id = 2; Assert.That(() => _eh.UpdateWith(e1, e2), Throws.ArgumentException); }
public void DoesntThrowIfOneOfIdsIsZero() { Entry e1 = new Entry(); Entry e2 = TestingShared.GenerateEntryPage() .Entry; e1.Id = 0; e2.Id = 2; _eh.UpdateWith(e1, e2); }
public void SelectsCommentsAsExpected() { EntryPage ep = TestingShared.GenerateEntryPage(true); List <Comment[]> result = _picker.Pick(ep); Assert.AreEqual(1, result.Count); Assert.AreEqual( 3 , result[0] .Length ); }
public void EmptyPageGetsAllDataWhenMergedInto() { Entry e1 = new Entry(); EntryPage p2 = TestingShared.GenerateEntryPage(); e1.Id = 1; p2.Entry.Id = 1; _eh.UpdateWith(e1, p2.Entry); Assert.That(e1.Text, Is.Not.Null.And.Not.Empty); Assert.That(e1.Subject, Is.Not.Null.And.Not.Empty); Assert.IsNotNull(e1.Date); Assert.AreNotEqual(default(long), e1.Id); }
public void InsertCommentsFromMiddlePages() { // Three original pages. EntryPage p1 = TestingShared.GenerateEntryPage(true, 0); EntryPage p2 = TestingShared.GenerateEntryPage(true, 50); EntryPage p3 = TestingShared.GenerateEntryPage(true, 100); _rh.MergeFrom(p1, p3); _rh.MergeFrom(p1, p2); Comment[] comments = _rh.EnumerateAll(p1.Replies) .ToArray(); Assert.AreEqual(12, comments.Length, "Comments should've been added."); CollectionAssert.AllItemsAreUnique(comments.Select(z => z.Id)); CollectionAssert.IsOrdered(comments.Select(z => z.Id)); }
public void ThrowsIfNoTargetSpecified() { EntryPage other = TestingShared.GenerateEntryPage(); Assert.That(() => _eph.AddData(null, other), Throws.ArgumentNullException); }