Пример #1
0
        public async Task ShouldNotAllowSavingCommitsWithSameStreamIdAndVersion()
        {
            var commits = Data.CreateValidCommits(2);
            var c1      = commits[0];
            var c2      = commits[1];

            c2.StreamId = c1.StreamId;
            c2.Version  = c1.Version;

            var sut = Fixture.Persistence;

            using (var tx = Util.CreateTransactionScope())
                using (var sess = sut.OpenSession())
                {
                    var ok = await sess.SaveAsync(c1).ConfigureAwait(false);

                    Assert.True(ok);

                    await AssertException.Is <VersionConflictException>(
                        () => sess.SaveAsync(c2),
                        ex => !string.IsNullOrEmpty(ex.StreamId) && ex.Version > 0);

                    tx.Complete();
                }
        }
Пример #2
0
        public async Task SaveCommitShouldThrowOnNullArg()
        {
            var sut = Fixture.Persistence;

            using (var sess = sut.OpenSession())
            {
                await AssertException.Is <ArgumentNullException>(() => sess.SaveAsync(null));
            }
        }
Пример #3
0
        public async Task InvalidCommitsShouldBeRejected(Commit invalidCommit, int testIndex)
        {
            var sut = Fixture.Persistence;

            using (var sess = sut.OpenSession())
            {
                await AssertException.Is <InvalidPersistenceDataException>(() => sess.SaveAsync(invalidCommit), testIndex : testIndex);
            }
        }
Пример #4
0
        public async Task LoadCommitsShouldThrowOnNullArg()
        {
            var sut = Fixture.Persistence;

            using (var sess = sut.OpenSession())
            {
                await AssertException.Is <ArgumentNullException>(() => sess.LoadCommitsAsync(null));

                await AssertException.Is <ArgumentException>(() => sess.LoadCommitsAsync(string.Empty));
            }
        }