Пример #1
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));
        }
Пример #2
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));
        }
        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);
        }
Пример #4
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));
        }