예제 #1
0
        public void PatchEmpty_PatchDataBase_WithEmptyDb_ShouldCreateTables_ShouldBeAbleToInsertData()
        {
            try
            {
                ITransaction transaction = CreateTransaction();

                int        id     = 36;
                RootEntity entity = CreateRootEntityWithoutNullValues(id);
                entity.LeafEntities.Add(CreateLeafEntityA(id, 1));
                entity.LeafEntities.Add(CreateLeafEntityB(id, 2));
                entity.Persist(transaction);
                transaction.Commit();

                transaction = CreateTransaction();
                RootEntity loadedEntity = LoadRootEntityWithId(transaction, id);
                transaction.Commit();

                AssertTwoRootEntitiesEquals(entity, loadedEntity);
            }
            catch (System.Exception e)
            {
                LogManager.GetLogger(typeof(DbGatePatchEmptyDbTests)).Fatal("Exception during test", e);
                Assert.Fail(e.Message);
            }
        }
예제 #2
0
        public void PatchEmpty_PatchDataBase_WithEmptyDb_ShouldCreatePrimaryKeys_ShouldNotAbleToPutDuplicateData()
        {
            ITransaction transaction = CreateTransaction();

            int        id     = 37;
            RootEntity entity = CreateRootEntityWithoutNullValues(id);

            entity.LeafEntities.Add(CreateLeafEntityA(id, 1));
            entity.LeafEntities.Add(CreateLeafEntityB(id, 1));
            Assert.Throws <PersistException>(() => entity.Persist(transaction));

            transaction.Commit();
            transaction.Close();
        }
예제 #3
0
        public void PatchEmpty_PatchDataBase_WithEmptyDb_ShouldCreateForeignKeys_ShouldNotAbleToInconsistantData()
        {
            ITransaction transaction = CreateTransaction();

            int        id     = 38;
            RootEntity entity = CreateRootEntityWithoutNullValues(id);

            entity.Persist(transaction);

            var leafEntityA = CreateLeafEntityA(id, 1);

            leafEntityA.Persist(transaction);

            var leafEntityB = CreateLeafEntityA(id + 1, 1);

            Assert.Throws <PersistException>(() => leafEntityB.Persist(transaction));

            transaction.Commit();
            transaction.Close();
        }