Exemple #1
0
        //This is a quick test for "ShouldCommit"
        public static void AssertShouldCommit()
        {
            var smallBatch = new CommitBatchPolicy(10);
            var bigBatch   = new CommitBatchPolicy(1000);

            var reloadPositionCatchedUp       = new ProjectionPosition(444, 440, 444);
            var rebuildFirstPositionCatchedUp = new ProjectionPosition(444, null, 444);

            var reloadCatchingUp900Uncomitted = new ProjectionPosition(999, 99, 8747235);

            if (smallBatch.ShouldCommit(reloadPositionCatchedUp) == false)
            {
                throw new InvalidOperationException("failed expectation: small batch to commit on " + nameof(reloadPositionCatchedUp));
            }

            if (bigBatch.ShouldCommit(reloadPositionCatchedUp) == false)
            {
                throw new InvalidOperationException("failed expectation: big batch to commit on " + nameof(reloadPositionCatchedUp));
            }

            if (smallBatch.ShouldCommit(rebuildFirstPositionCatchedUp) == false)
            {
                throw new InvalidOperationException("failed expectation: small batch to commit on " + nameof(rebuildFirstPositionCatchedUp));
            }

            if (smallBatch.ShouldCommit(rebuildFirstPositionCatchedUp) == false)
            {
                throw new InvalidOperationException("failed expectation: big batch to commit on " + nameof(rebuildFirstPositionCatchedUp));
            }

            if (smallBatch.ShouldCommit(reloadCatchingUp900Uncomitted) == false)
            {
                throw new InvalidOperationException("failed expectation: small batch to commit on " + nameof(reloadCatchingUp900Uncomitted));
            }

            if (bigBatch.ShouldCommit(reloadCatchingUp900Uncomitted))
            {
                throw new InvalidOperationException("failed expectation: big batch not to commit on " + nameof(reloadCatchingUp900Uncomitted));
            }
        }