ReviewRevision ISessionAdapter.GetPreviousRevision(ReviewRevision revision) { Assert.That(revision, Is.AnyOf(Revisions.OfType <object>().ToArray())); if (revision.RevisionNumber == 1) { return(null); } return(Revisions.Single(x => x.RevisionNumber == revision.RevisionNumber - 1)); }
void ISessionAdapter.Save(Review review) { Assert.That(review.RevisionId, Is.AnyOf(Revisions.Select(x => (object)x.Id).ToArray()), "Review must be linked to valid revision"); Assert.That(review.UserId, Is.AnyOf(Users.Select(x => (object)x.Id).ToArray()), "Review must be linked to valid user"); var user = Users.Single(x => x.Id == review.UserId); var revision = Revisions.Single(x => x.Id == review.RevisionId); if (Reviews.TryGetValue(user, revision, out var original)) { Assert.That(review, Is.SameAs(original), "Do not overwrite review"); } else { Reviews[user, revision] = review; } }
ReviewRevision ISessionAdapter.GetRevision(Guid revisionId) { Assert.That(revisionId, Is.AnyOf(Revisions.Select(x => (object)x.Id).ToArray())); return(Revisions.Single(x => x.Id == revisionId)); }