Skip to content

Commit

Permalink
Fix for dotMorten#51
Browse files Browse the repository at this point in the history
  • Loading branch information
yorek committed Oct 8, 2020
1 parent 8d40044 commit a194bf3
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 22 deletions.
11 changes: 8 additions & 3 deletions src/Microsoft.SqlServer.Types.Tests/Geography/WktTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using Microsoft.SqlServer.Types.Tests.Geometry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Data.SqlTypes;
#if NETCOREAPP
using Microsoft.Data.SqlClient;
#else
using System.Data.SqlClient;
#endif

namespace Microsoft.SqlServer.Types.Tests.Geography
{
Expand All @@ -14,7 +19,7 @@ public class WktTests
[WorkItem(13)]
public void UserSubmittedIssue_WKT2()
{
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString))
using (var conn = new SqlConnection(DBTests.ConnectionString))
{
conn.Open();
var id = SqlGeography.Parse("LINESTRING (-122.36 47.656, -122.343 47.656)");
Expand All @@ -38,7 +43,7 @@ public void UserSubmittedIssue_WKT2()
[WorkItem(13)]
public void UserSubmittedIssue_WKT3()
{
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString))
using (var conn = new SqlConnection(DBTests.ConnectionString))
{
conn.Open();
var id = SqlGeography.Parse("LINESTRING (-122.36 47.656, -122.343 47.656)");
Expand All @@ -56,7 +61,7 @@ public void UserSubmittedIssue_WKT3()
[WorkItem(14)]
public void UserSubmittedIssue_WKT4()
{
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString))
using (var conn = new SqlConnection(DBTests.ConnectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
Expand Down
14 changes: 9 additions & 5 deletions src/Microsoft.SqlServer.Types.Tests/Geometry/DBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
#if NETCOREAPP
using Microsoft.Data.SqlClient;
#else
using System.Data.SqlClient;
#endif

namespace Microsoft.SqlServer.Types.Tests.Geometry
{
Expand All @@ -20,7 +24,7 @@ public class DBTests : IDisposable
{
const string connstr = @"Data Source=(localdb)\mssqllocaldb;Integrated Security=True;AttachDbFileName=";

private System.Data.SqlClient.SqlConnection conn;
private SqlConnection conn;
private static string path;
private static object lockObj = new object();
static DBTests()
Expand All @@ -34,7 +38,7 @@ public static void Init()
{
path = Path.Combine(new FileInfo(typeof(DBTests).Assembly.Location).Directory.FullName, "UnitTestData.mdf");
CreateSqlDatabase(path);
using (var conn = new System.Data.SqlClient.SqlConnection(connstr + path))
using (var conn = new SqlConnection(connstr + path))
{
conn.Open();
var cmd = conn.CreateCommand();
Expand All @@ -54,7 +58,7 @@ public static void Init()
public DBTests()
{
Init();
conn = new System.Data.SqlClient.SqlConnection(ConnectionString);
conn = new SqlConnection(ConnectionString);
conn.Open();
}

Expand All @@ -65,7 +69,7 @@ private static void CreateSqlDatabase(string filename)
File.Delete(filename);
if (File.Exists(filename.Replace(".mdf","_log.ldf")))
File.Delete(filename.Replace(".mdf", "_log.ldf"));
using (var connection = new System.Data.SqlClient.SqlConnection(
using (var connection = new SqlConnection(
@"Data Source=(localdb)\mssqllocaldb;Initial Catalog=master; Integrated Security=true;"))
{
connection.Open();
Expand Down
9 changes: 7 additions & 2 deletions src/Microsoft.SqlServer.Types.Tests/Geometry/WktTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#if NETCOREAPP
using Microsoft.Data.SqlClient;
#else
using System.Data.SqlClient;
#endif

namespace Microsoft.SqlServer.Types.Tests.Geometry
{
Expand Down Expand Up @@ -107,7 +112,7 @@ public void EmptyGeometriesFromString(string parameter)
[TestMethod]
public void MultiLineStringFromString()
{
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString))
using (var conn = new SqlConnection(DBTests.ConnectionString))
{
conn.Open();
using (var cmd = conn.CreateCommand())
Expand Down Expand Up @@ -183,7 +188,7 @@ public void GeometryCollectionFromString()
[WorkItem(13)]
public void UserSubmittedIssue_WKT1()
{
using (var conn = new System.Data.SqlClient.SqlConnection(DBTests.ConnectionString))
using (var conn = new SqlConnection(DBTests.ConnectionString))
{
conn.Open();
var id = SqlGeometry.Parse("LINESTRING (100 100, 20 180, 180 180)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp2.1'">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<ProjectReference Include="..\Microsoft.SqlServer.Types\Microsoft.SqlServer.Types.csproj" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<PackageReference Include="Microsoft.SqlServer.Types" Version="14.0.1016.290" />
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.SqlServer.Types/ISqlSpatialGridIndexable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.SqlServer.Server;
using Microsoft.Data.SqlClient.Server;

namespace Microsoft.SqlServer.Types
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.SqlClient">
<Version>4.5.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="System.Memory" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Microsoft.SqlServer.Types/SqlGeography.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.SqlServer.Server;
using Microsoft.Data.SqlClient.Server;
using System;
using System.Data.SqlTypes;
using System.IO;
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.SqlServer.Types/SqlGeometry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.SqlServer.Server;
using Microsoft.Data.SqlClient.Server;
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
Expand Down Expand Up @@ -206,10 +206,10 @@ public SqlInt32 STNumCurves()
{
if (IsNull || _geometry.IsEmpty) return SqlInt32.Null;

if (_geometry.Type == OGCGeometryType.LineString)
return _geometry.IsEmpty ? 0 : _geometry.NumPoints - 1;
if (_geometry.Type == OGCGeometryType.LineString)
return _geometry.IsEmpty ? 0 : _geometry.NumPoints - 1;

if (_geometry.Type == OGCGeometryType.CircularString)
if (_geometry.Type == OGCGeometryType.CircularString)
{
if (_geometry.IsEmpty) return 0;
return (_geometry.NumPoints - 1) / 2;
Expand All @@ -218,7 +218,7 @@ public SqlInt32 STNumCurves()
return _geometry.NumRings;
if (_geometry.Type != OGCGeometryType.CompoundCurve)
return SqlInt32.Null;
return _geometry.NumSegments;
return _geometry.NumSegments;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.SqlServer.Types/SqlHierarchyId.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.SqlServer.Server;
using Microsoft.Data.SqlClient.Server;
using Microsoft.SqlServer.Types.SqlHierarchy;
using System;
using System.Collections;
Expand Down

0 comments on commit a194bf3

Please sign in to comment.