Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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;
            }
        }
Ejemplo n.º 3
0
        ReviewRevision ISessionAdapter.GetRevision(Guid revisionId)
        {
            Assert.That(revisionId, Is.AnyOf(Revisions.Select(x => (object)x.Id).ToArray()));

            return(Revisions.Single(x => x.Id == revisionId));
        }