public static void CountAsync_Returns_CountWithOwnSession()
        {
            var repo   = new BraveRepository(Factory);
            var result = 0;

            Assert.DoesNotThrowAsync(async() => result = await repo.CountAsync <ITestSession>());
            Assert.That(result, Is.Positive);
        }
        public static void CountAsync_Returns_Count()
        {
            var repo   = new BraveRepository(Factory);
            var result = 0;

            Assert.DoesNotThrowAsync(async() => result = await repo.CountAsync(Connection));
            Assert.That(result, Is.Positive);
        }
        public static void GetKeyAsync_Returns_WithoutJoins()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrowAsync(async() => result = await repo.GetKeyAsync(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void GetKeyAsync_Returns_WithoutJoinsCreatingASessionItself()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrow(() => result = repo.GetKeyAsync <ITestSession>(1).Result);
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Ejemplo n.º 5
0
        public static void GetAllAsyncITestSession_Returns_CorrectAmountCreatingASessionItself()
        {
            var repo = new BraveRepository(Factory);
            IEnumerable <Brave> results = null;

            Assert.DoesNotThrowAsync(async() => results = await repo.GetAllAsync <ITestSession>());
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.Not.Empty);
            results.Should().HaveCount(x => x > 0);
        }
        public static void GetAllITestSession_Returns_CorrectAmountCreatingASessionItself()
        {
            var repo = new BraveRepository(Factory);
            IEnumerable <Brave> results = null;

            Assert.DoesNotThrow(() => results = repo.GetAll <ITestSession>());
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.Not.Empty);
            Assert.That(results.Count(), Is.EqualTo(3));
        }
        public static void GetAll_Returns_CorrectAmountWithoutJoins()
        {
            var repo = new BraveRepository(Factory);
            IEnumerable <Brave> results = null;

            Assert.DoesNotThrow(() => results = repo.GetAll(Connection));
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.Not.Empty);
            Assert.That(results.Count(), Is.EqualTo(3));
        }
        public static void Get_Returns_WithoutJoins()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrow(() => result = repo.Get(new Brave {
                Id = 1
            }, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void CountAsync_Returns_CountUnitOfWork()
        {
            var repo   = new BraveRepository(Factory);
            var result = 0;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrowAsync(async() => result = await repo.CountAsync(uow));
                Assert.That(result, Is.Positive);
            }
        }
        public static void GetAll_Returns_CorrectAmount()
        {
            var repo = new BraveRepository(Factory);
            IEnumerable <Brave> results = null;

            Assert.DoesNotThrow(() => results = repo.GetAllJoins(Connection));
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.Not.Empty);
            Assert.That(results.First().New, Is.Not.Null);
            Assert.That(results.First().New.World, Is.Not.Null);
        }
        public static void GetAsync_Returns_WithoutJoinsCreatingASessionItself()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrowAsync(async() => result = await repo.GetAsync <ISession>(new Brave {
                Id = 1
            }));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void GetKeyAsync_Returns_WithoutJoinsWithUnitOrWork()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrowAsync(async() => result = await repo.GetKeyAsync(1, uow));
            }
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void Get_Returns_WithJoins()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            Assert.DoesNotThrow(() => result = repo.GetWithJoins(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
            Assert.That(result.New.Key, Is.EqualTo(3));
            Assert.That(result.New.World.Id, Is.EqualTo(1));
            Assert.That(result.New.World.Guid, Is.Not.Null);
        }
Ejemplo n.º 14
0
        public static void GetAll_Returns_CorrectAmountWithoutJoinsWithUnitOfWork()
        {
            var repo = new BraveRepository(Factory);
            IEnumerable <Brave> results = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrow(() => results = repo.GetAll(uow));
            }
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.Not.Empty);
            results.Should().HaveCount(x => x > 0);
        }
        public static void GetAll_Returns_CorrectAmountWithUnitOfWork()
        {
            var repo = new BraveRepository(Factory);
            IEnumerable <Brave> results = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrowAsync(async() => results = await repo.GetAllAsync(uow));
            }
            Assert.That(results, Is.Not.Null);
            Assert.That(results, Is.Not.Empty);
            Assert.That(results.Count(), Is.EqualTo(3));
        }
Ejemplo n.º 16
0
        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 Get_Returns_WithoutJoinsAndUnitOfWork()
        {
            var   repo   = new BraveRepository(Factory);
            Brave result = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrow(() => result = repo.Get(new Brave {
                    Id = 1
                }, uow));
            }
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
Ejemplo n.º 18
0
        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));
        }
Ejemplo n.º 19
0
        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));
        }
Ejemplo n.º 20
0
        public static void DeleteKey_Removes_EntityOnKeyWithSessionGeneric()
        {
            var repo     = new BraveRepository(Factory);
            var result   = false;
            var expected = new Brave {
                NewId = 2
            };
            var resultBrave = new Brave();

            Assert.DoesNotThrow(() =>
            {
                repo.SaveOrUpdate <ITestSession>(expected);
                result      = repo.DeleteKey <ITestSession>(expected.Id);
                resultBrave = repo.Get <ITestSession>(expected);
            });
            Assert.That(result, Is.True);
            Assert.That(resultBrave, Is.Null);
        }
Ejemplo n.º 21
0
        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));
        }
Ejemplo n.º 22
0
        public static void DeleteKeyAsync_Removes_EntityOnKey()
        {
            var repo        = new BraveRepository(Factory);
            var result      = false;
            var expected    = 2;
            var resultBrave = new Brave();

            Assert.DoesNotThrowAsync(async() =>
            {
                using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
                {
                    result      = await repo.DeleteKeyAsync(expected, uow);
                    resultBrave = await repo.GetKeyAsync(expected, uow);
                    uow.Rollback();
                }
            }
                                     );
            Assert.That(result, Is.True);
            Assert.That(resultBrave, Is.Null);
        }
Ejemplo n.º 23
0
        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));
        }