@Test
public void testGetTransform(){

    // Setup an envelope in WGS84
    GeneralEnvelope envelope = new GeneralEnvelope(DefaultGeographicCRS.WGS84);
    envelope.setEnvelope(0, 0, 10, 10);
    
    // Setup a rectangle
    Rectangle rect = new Rectangle(0, 0, 20, 20);
    GridEnvelope2D env = new GridEnvelope2D(rect);
    
    // GridGeometry
    GridGeometry2D gg2D = new GridGeometry2D(env, envelope);
    
    // Transform
    MathTransform tr = gg2D.getGridToCRS2D(PixelOrientation.UPPER_LEFT);
    
    // Check if with CELL_CENTER, the transformation returned is the same
    assertSame(tr, Utilities.getOriginalGridToWorld(tr, PixelInCell.CELL_CENTER));
    
    // Check with the CELL_CORNER and the following transformation, the result is a 
    // Linear Transform
    assertTrue(LinearTransform.class.isAssignableFrom(Utilities.getOriginalGridToWorld(tr,
            PixelInCell.CELL_CORNER).getClass()));
    
    // Check that a Linear Transform is returned also with an Identity transform 
    rect = new Rectangle(0, 0, 10, 10);
    env = new GridEnvelope2D(rect);
    
    // GridGeometry
    gg2D = new GridGeometry2D(env, envelope);
    
    // Transform
    tr = gg2D.getGridToCRS2D(PixelOrientation.UPPER_LEFT);
    
    assertTrue(LinearTransform.class.isAssignableFrom(Utilities.getOriginalGridToWorld(tr,
            PixelInCell.CELL_CORNER).getClass()));
}