public static void _2_SaveOrUpdate_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.DoesNotThrow(() => result = repo.SaveOrUpdate <ITestSession>(expected));
            Assert.That(result, Is.EqualTo(++maxId));
        }
        public static void SaveOrUpdate_Returns_IdForUpdatedEnitiyCreatesOwnUnitOfWork()
        {
            var repo       = new BraveRepository(Factory);
            var expectedId = 2;
            var expected   = repo.GetWithJoins(expectedId, Connection);
            var original   = expected.New;

            expected.NewId = 1;
            int resultId = 0;

            Assert.DoesNotThrow(() => resultId = repo.SaveOrUpdate <ITestSession>(expected));
            Assert.That(expectedId, Is.EqualTo(resultId));
            var result = repo.GetWithJoins(expectedId, Connection);

            Assert.That(result.New, Is.Not.EqualTo(original));
            Assert.That(result.NewId, Is.EqualTo(1));
        }
        public static void _1_SaveOrUpdate_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(uow).Max(x => x.Id);
                Assert.DoesNotThrow(() => result = repo.SaveOrUpdate(expected, uow));
            }
            Assert.That(result, Is.EqualTo(++maxId));
        }
        public static void DeleteByKeyAsync_Removes_EntityOnKeyWithSessionGeneric()
        {
            var repo     = new BraveRepository(Factory);
            var result   = false;
            var expected = new Brave()
            {
                NewId = 2
            };
            var resultBrave = new Brave();

            Assert.DoesNotThrowAsync(async() =>
            {
                repo.SaveOrUpdate <ITestSession>(expected);
                result      = await repo.DeleteByKeyAsync <ITestSession>(expected.Id);
                resultBrave = await repo.GetAsync <ITestSession>(expected);
            });
            Assert.That(result, Is.True);
            Assert.That(resultBrave, Is.Null);
        }
        public static void SaveOrUpdate_Returns_IdForUpdatedEnitiy()
        {
            var       repo       = new BraveRepository(Factory);
            const int expectedId = 2;
            var       resultId   = 0;

            New original = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                var expected = repo.GetWithJoins(expectedId, Connection);
                original       = expected.New;
                expected.NewId = 2;
                Assert.DoesNotThrow(() => resultId = repo.SaveOrUpdate(expected, uow));
            }
            Assert.That(expectedId, Is.EqualTo(resultId));
            var result = repo.GetWithJoins(expectedId, Connection);

            Assert.That(result.New, Is.Not.EqualTo(original));
            Assert.That(result.NewId, Is.EqualTo(2));
        }