Ejemplo n.º 1
0
        public static void Get_Returns_CorrectAmountWithJoins()
        {
            var   factory = A.Fake <IDbFactory>();
            var   repo    = new BraveRepository(factory);
            Brave result  = null;

            Assert.DoesNotThrow(() => result = repo.Get(1, Connection));
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(1));
        }
        public static void GetAll_Returns_CorrectAmountWithoutJoins()
        {
            var factory = A.Fake <IDbFactory>();
            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 GetAll_Returns_CorrectAmount()
        {
            var factory = A.Fake <IDbFactory>();
            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);
        }
Ejemplo n.º 4
0
        public static void Reset_ClearsDictionary()
        {
            var repo = new BraveRepository(Factory);

            repo.GetKey <ITestSession>(1);
            var target = new SqlDialectHelper();

            target.Reset();
            var result = target.GetEntityState <Brave>();

            Assert.That(result.HasValue, Is.False);
        }
Ejemplo n.º 5
0
        public static void SetDialogueIfNeeded_SetsIsFroozenInDictionary()
        {
            var repo = new BraveRepository(Factory);

            repo.GetKey <ITestSession>(1);
            var target = new SqlDialectHelper();
            var result = target.GetEntityState <Brave>();

            Assert.That(result.HasValue, Is.True);
            Assert.That(result.Value, Is.True);
            Assert.That(OrmConfiguration.GetDefaultEntityMapping <Brave>().Dialect, Is.EqualTo(SqlDialect.SqLite));
        }
Ejemplo n.º 6
0
        public void Rollback_DoesNotThrow_OnDisposalAfterAlreadyBeingCalled()
        {
            var repo = new BraveRepository(Factory);

            Assert.DoesNotThrow(() => {
                using (var uow = Connection.UnitOfWork(IsolationLevel.Serializable))
                {
                    var result = repo.SaveOrUpdate(new Brave {
                        NewId = 3
                    }, uow);
                    result.Should().BePositive();
                    uow.Rollback();
                }
            });
        }
        public static void SaveOrUpdate_Returns_IdForInsertedEnitiy()
        {
            var factory  = A.Fake <IDbFactory>();
            var repo     = new BraveRepository(factory);
            var expected = new Brave
            {
                NewId = 1
            };
            int result = 0;

            using (var transaction = Connection.UnitOfWork())
            {
                Assert.DoesNotThrow(() => result = repo.SaveOrUpdate(expected, transaction));
            }
            Assert.That(result, Is.EqualTo(4));
        }
        public static void SaveOrUpdate_Returns_IdForUpdatedEnitiy()
        {
            var factory    = A.Fake <IDbFactory>();
            var repo       = new BraveRepository(factory);
            var expectedId = 1;
            var expected   = repo.Get(expectedId, Connection);
            var original   = expected.New;

            expected.NewId = 2;
            int resultId = 0;

            using (var transaction = Connection.UnitOfWork())
            {
                Assert.DoesNotThrow(() => resultId = repo.SaveOrUpdate(expected, transaction));
            }
            Assert.That(expectedId, Is.EqualTo(resultId));
            var result = repo.Get(expectedId, Connection);

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