コード例 #1
0
        public void ColumnPersist_Delete_WithFieldsDifferentTypesStartWithNullEndWithNull_ShouldDelete()
        {
            try
            {
                IDbConnection connection  = SetupTables();
                ITransaction  transaction = CreateTransaction(connection);

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

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

                transaction = CreateTransaction(connection);
                IColumnTestEntity reLoadedEntity = new ColumnTestEntityFields();
                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);
            }
        }
コード例 #2
0
        public void ColumnPersist_Insert_WithFieldsDifferentTypesWithoutNull_ShouldEqualWhenLoaded()
        {
            try
            {
                IDbConnection connection  = SetupTables();
                ITransaction  transaction = CreateTransaction(connection);

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

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

                transaction = CreateTransaction(connection);
                IColumnTestEntity loadedEntity = new ColumnTestEntityFields();
                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);
            }
        }