public static void GetKeyAsync_Returns_WithoutJoinsWithoutIEntity()
        {
            var repo   = new NewRepository(Factory);
            New result = null;

            Assert.DoesNotThrowAsync(async() => result = await repo.GetKeyAsync(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Key, Is.EqualTo(1));
        }
        public static void GetAll_Returns_CorrectAmountWithoutJoinsAndIsNotIEntity()
        {
            var repo = new NewRepository(Factory);
            IEnumerable <New> 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_WithoutJoinsAndNotIEntity()
        {
            var repo   = new NewRepository(Factory);
            New result = null;

            Assert.DoesNotThrow(() => result = repo.Get(new New {
                Key = 1
            }, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Key, Is.EqualTo(1));
        }
        public static void GetKeyAsync_Returns_WithoutJoinsWithUnitOrWorkWithoutIEnity()
        {
            var repo   = new NewRepository(Factory);
            New 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.Key, Is.EqualTo(1));
        }
        public static void GetAll_Returns_CorrectAmountWithoutJoinsWithUnitOfWorkAndIsNotIEntity()
        {
            var repo = new NewRepository(Factory);
            IEnumerable <New> 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);
            Assert.That(results.Count(), Is.EqualTo(3));
        }
        public static void Get_Returns_WithoutJoinsAndUnitOfWorkAndNotIEntity()
        {
            var repo   = new NewRepository(Factory);
            New result = null;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                Assert.DoesNotThrow(() => result = repo.Get(new New {
                    Key = 1
                }, uow));
            }
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Key, Is.EqualTo(1));
        }
コード例 #7
0
        public static void SaveOrUpdate_Returns_IdForUpdatedEnitityAndEntityWithoutIEntity()
        {
            var       repo       = new NewRepository(Factory);
            const int expectedId = 3;
            var       resultId   = 0;

            int?oridinalId;

            using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
            {
                var expected = repo.GetKey(expectedId, uow);
                oridinalId       = expected.WorldId;
                expected.WorldId = 3;
                Assert.DoesNotThrow(() => resultId = repo.SaveOrUpdate(expected, uow));
            }
            Assert.That(expectedId, Is.EqualTo(resultId));
            var result = repo.GetKey(expectedId, Connection);

            Assert.That(result.WorldId, Is.Not.EqualTo(oridinalId));
            Assert.That(result.WorldId, Is.EqualTo(3));
        }