Question

When I create two tables that contain a geography column and use tSQlt.AssertEqualsTable, the test fails with:

failed: Invalid operator for data type. Operator equals equal to, type equals geography.{,1}

Does anyone know if tSQLt supports the geography data type for table comparisons?

Was it helpful?

Solution 2

It is currently not supported but will be included in the next/future release.

OTHER TIPS

tSQLt has since been updated to include a more detailed error message for incompatible data types. If you use one of the incompatible data types you should see this message:

(Error) The table contains a datatype that is not supported for 
tSQLt.AssertEqualsTable. Please refer to http://tsqlt.org/user-
guide/assertions/assertequalstable/ for a list of unsupported datatypes.

The list of incompatible types are:

  • XML
  • Text
  • NText
  • Image
  • Geography
  • Geometry
  • Rowversion
  • Any CLR data type that is not marked as both Comparable and Byte Ordered

However, there is almost always a work-around. You can convert the value to a compatible data type before comparing it, as in the following example:

EXEC tSQLt.NewTestClass 'DeliveryTests';
GO

CREATE PROCEDURE DeliveryTests.[test Order is matched to Customer location]
AS
BEGIN
  EXEC tSQLt.FakeTable 'Sales.Customers';
  EXEC tSQLt.FakeTable 'Sales.Orders';

  INSERT INTO Sales.Customers (CustomerId, Location) 
       VALUES (1, geography::Point(47.65100, -122.34900, 4326));
  INSERT INTO Sales.Orders (OrderId, CustomerId) 
    VALUES (5, 1);

  SELECT OrderId, Location.ToString() AS Location
    INTO DeliveryTests.Actual
    FROM Delivery.OrderDestinations;

  SELECT TOP(0) *
    INTO DeliveryTests.Expected
    FROM DeliveryTests.Actual;

  INSERT INTO DeliveryTests.Expected (OrderId, Location) 
     VALUES (5, geography::Point(47.65100, -122.34900, 4326).ToString());

  EXEC tSQLt.AssertEqualsTable 'DeliveryTests.Expected', 
                               'DeliveryTests.Actual';
END;
GO
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top