0

I need it for the unit test of MakeValid method. All I can find, is invalid text, which is not getting converted to the SqlGeography. So I need to create invalid SqlGeograpy object somehow.

using System.Data.SqlTypes;         //use Nuget System.Data.SqlClient
using Microsoft.SqlServer.Types;    //Microsoft.SqlServer.Types.dll
...
static void MakeValidTest() {
    string pointString = "POINT (-112.11436060512261 33.860383682237021)"; 
    var sqlString = new SqlString(pointString, 4326);
    var sqlGeography = SqlGeography.Parse(sqlString);  // how to get invalid Sql Geography???

    sqlGeography = sqlGeography.MakeValid();
    Console.WriteLine(sqlGeography);
}

PS Similar example with DbGeography, or with SQL could be also very helpful.. FYI: It's related to writing SQLCLR methods.

sam sergiy klok
  • 526
  • 7
  • 17
  • Is it your job to unit test *third party's libraries*? Because that's a fairly *odd* job to be engaged in. – Damien_The_Unbeliever Mar 19 '19 at 18:27
  • Damien, I'm writing several SQLCLR which convert text to geography data, also trying to fix invalid geography data. They more complex than simplified code example in my question. I want to unit test it, but I don't have INVALID geography to test.. maybe I can somehow change SqlGeography and make it bad. – sam sergiy klok Mar 19 '19 at 19:10

0 Answers0