示例#1
0
        public void ColumnPersist_Insert_WithExtsDifferentTypesWithoutNull_ShouldEqualWhenLoaded()
        {
            try
            {
                IDbConnection connection  = SetupTables();
                ITransaction  transaction = CreateTransaction(connection);

                Type type = typeof(ColumnTestEntityExts);
                TransactionFactory.DbGate.RegisterEntity(type, ColumnTestExtFactory.GetTableInfo(type),
                                                         ColumnTestExtFactory.GetFieldInfo(type));

                int id = (int)new PrimaryKeyGenerator().GetNextSequenceValue(transaction);
                IColumnTestEntity entity = new ColumnTestEntityExts();
                CreateEntityWithNonNullValues(entity);

                entity.Persist(transaction);
                transaction.Commit();

                transaction = CreateTransaction(connection);
                IColumnTestEntity loadedEntity = new ColumnTestEntityExts();
                LoadEntityWithId(transaction, loadedEntity, id);
                transaction.Commit();
                connection.Close();

                AssertTwoEntitiesEquals(entity, loadedEntity);
            }
            catch (System.Exception e)
            {
                LogManager.GetLogger(typeof(DbGatePatchEmptyDbTests)).Fatal("Exception during test", e);
                Assert.Fail(e.Message);
            }
        }
示例#2
0
        public void ColumnPersist_Delete_WithExtsDifferentTypesStartWithNullEndWithNull_ShouldDelete()
        {
            try
            {
                IDbConnection connection  = SetupTables();
                ITransaction  transaction = CreateTransaction(connection);

                Type type = typeof(ColumnTestEntityExts);
                TransactionFactory.DbGate.RegisterEntity(type, ColumnTestExtFactory.GetTableInfo(type),
                                                         ColumnTestExtFactory.GetFieldInfo(type));

                int id = (int)new PrimaryKeyGenerator().GetNextSequenceValue(transaction);
                IColumnTestEntity newEntity = new ColumnTestEntityExts();
                CreateEntityWithNullValues(newEntity);
                newEntity.Persist(transaction);
                transaction.Commit();

                transaction = CreateTransaction(connection);
                IColumnTestEntity loadedEntity = new ColumnTestEntityExts();
                LoadEntityWithId(transaction, loadedEntity, id);
                loadedEntity.Status = EntityStatus.Deleted;
                loadedEntity.Persist(transaction);
                transaction.Commit();

                transaction = CreateTransaction(connection);
                IColumnTestEntity reLoadedEntity = new ColumnTestEntityExts();
                bool loaded = LoadEntityWithId(transaction, reLoadedEntity, id);
                transaction.Commit();
                connection.Close();

                Assert.IsFalse(loaded);
            }
            catch (System.Exception e)
            {
                LogManager.GetLogger(typeof(DbGatePatchEmptyDbTests)).Fatal("Exception during test", e);
                Assert.Fail(e.Message);
            }
        }