public static void _3_SaveOrUpdateAsync_Returns_IdForInsertedEnitiyCreatesOwnUnitOfWork()
        {
            var repo     = new BraveRepository(Factory);
            var expected = new Brave
            {
                NewId = 1
            };
            var result = 0;
            var maxId  = repo.GetAll <ITestSession>().Max(x => x.Id);

            Assert.DoesNotThrowAsync(async() => result = await repo.SaveOrUpdateAsync <ITestSession>(expected));
            Assert.That(result, Is.EqualTo(++maxId));
        }
        public static void _3_SaveOrUpdateAsync_Returns_IdForInsertedEnitiy()
        {
            var repo     = new BraveRepository(Factory);
            var expected = new Brave
            {
                NewId = 1
            };
            var result = 0;
            int maxId;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                maxId = repo.GetAll <ITestSession>().Max(x => x.Id);
                Assert.DoesNotThrowAsync(async() => result = await repo.SaveOrUpdateAsync(expected, uow));
            }
            Assert.That(result, Is.EqualTo(++maxId));
        }
        public static void SaveOrUpdateAsync_Returns_IdForUpdatedEnitiyCreatesOwnUnitOfWork()
        {
            var repo       = new BraveRepository(Factory);
            var expectedId = 1;
            var expected   = repo.GetWithJoins(expectedId, Connection);
            var original   = expected.New;

            expected.NewId = 3;
            var result = 0;

            Assert.DoesNotThrowAsync(async() => result = await repo.SaveOrUpdateAsync <ITestSession>(expected));

            Assert.That(expectedId, Is.EqualTo(result));
            var actual = repo.GetWithJoins(expectedId, Connection);

            Assert.That(actual.New, Is.Not.EqualTo(original));
            Assert.That(actual.NewId, Is.EqualTo(3));
        }
        public static void SaveOrUpdateAsync_Returns_IdForUpdatedEnitiy()
        {
            var       repo       = new BraveRepository(Factory);
            const int expectedId = 3;
            var       result     = 0;

            New original = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                var expected = repo.GetWithJoins(expectedId, Connection);
                original       = expected.New;
                expected.NewId = 1;
                Assert.DoesNotThrowAsync(async() => result = await repo.SaveOrUpdateAsync(expected, uow));
            }
            Assert.That(expectedId, Is.EqualTo(result));
            var actual = repo.GetWithJoins(expectedId, Connection);

            Assert.That(actual.New, Is.Not.EqualTo(original));
            Assert.That(actual.NewId, Is.EqualTo(1));
        }