Skip to content

Commit 5a9ecd0

Browse files
Merge pull request #1 from MartinCarpentier/feature/change-project-naming
Feature/change project naming
2 parents b5b8d90 + 98165f2 commit 5a9ecd0

68 files changed

Lines changed: 2552 additions & 1895 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-build.yml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
name: Build and Tests
1+
name: 'Build and Test'
22

33
on:
44
push:
5-
branches: [ main ]
65
pull_request:
76
branches: [ main ]
87

98
jobs:
10-
build:
9+
Build:
1110

1211
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
working-directory: ./src
15+
1316
env:
1417
VSTEST_CONNECTION_TIMEOUT: 900
15-
18+
1619
steps:
17-
- uses: actions/checkout@v2
18-
- name: Setup .NET Core
19-
uses: actions/setup-dotnet@v1
20-
with:
21-
dotnet-version: '6.0.x'
22-
- name: Install dependencies
23-
run: dotnet restore
24-
- name: Build
25-
run: dotnet build --configuration Release --no-restore
26-
- name: Test
27-
run: dotnet test --no-restore --verbosity normal
20+
- uses: actions/checkout@v2
21+
- name: Setup .NET Core
22+
uses: actions/setup-dotnet@v1
23+
with:
24+
dotnet-version: |
25+
3.1.x
26+
5.0.x
27+
6.0.x
28+
- name: Install dependencies
29+
run: dotnet restore
30+
- name: Build solution
31+
run: dotnet build -c Release --no-restore /p:Version=1.2.3.4
32+
- name: Test
33+
run: dotnet test -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/
34+
- uses: codecov/codecov-action@v2
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
directory: ../coverage/
38+
flags: unittests
39+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,6 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
352+
353+
*.opencover.xml

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
[![Build and Test](https://github.com/GeoJSON-Net/GeoJSON.Text/actions/workflows/ci-build.yml/badge.svg?branch=main)](https://github.com/GeoJSON-Net/GeoJSON.Text/actions/workflows/ci-build.yml) [![codecov](https://codecov.io/gh/GeoJSON-Net/GeoJSON.Text/branch/main/graph/badge.svg?token=SE9XY1T8XO)](https://codecov.io/gh/GeoJSON-Net/GeoJSON.Text)
2+
3+
14
# GetJson.Text
25
.Net library for GeoJSON types & corresponding System.TExt.Json (de)serializers

src/GeoJSON.Text.Tests/CoordinateReferenceSystem/DefaultCrsTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using GeoJSON.Text.CoordinateReferenceSystem;
22
using GeoJSON.Text.Feature;
33
using GeoJSON.Text.Geometry;
4-
54
using NUnit.Framework;
5+
using System.Text.Json;
66

77
namespace GeoJSON.Text.Tests.CoordinateReferenceSystem
88
{
@@ -14,7 +14,7 @@ public void Can_Serialize_Does_Not_Output_Crs_Property()
1414
{
1515
var collection = new FeatureCollection();
1616

17-
var json = JsonConvert.SerializeObject(collection);
17+
var json = JsonSerializer.Serialize(collection);
1818

1919
Assert.IsTrue(!json.Contains("\"crs\""));
2020
}
@@ -23,8 +23,8 @@ public void Can_Serialize_Does_Not_Output_Crs_Property()
2323
public void Can_Deserialize_When_Json_Does_Not_Contain_Crs_Property()
2424
{
2525
var json = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";
26-
27-
var point = JsonConvert.DeserializeObject<Point>(json);
26+
27+
var point = JsonSerializer.Deserialize<Point>(json);
2828

2929
Assert.IsNull(point.CRS);
3030
}
@@ -34,7 +34,7 @@ public void Can_Deserialize_CRS_issue_89()
3434
{
3535
var json = "{\"coordinates\": [ 90.65464646, 53.2455662, 200.4567 ], \"type\": \"Point\", \"crs\": { \"type\": \"name\", \"properties\": { \"name\": \"urn:ogc:def:crs:OGC:1.3:CRS84\" }}}";
3636

37-
var point = JsonConvert.DeserializeObject<Point>(json);
37+
var point = JsonSerializer.Deserialize<Point>(json);
3838

3939
Assert.IsNotNull(point.CRS);
4040
Assert.AreEqual(CRSType.Name, point.CRS.Type);
@@ -47,7 +47,7 @@ public void Can_Serialize_CRS_issue_89()
4747
"{\"type\":\"Point\",\"coordinates\":[34.56,12.34],\"crs\":{\"properties\":{\"name\":\"TEST NAME\"},\"type\":\"name\"}}";
4848
var point = new Point(new Position(12.34, 34.56)) { CRS = new NamedCRS("TEST NAME") };
4949

50-
var json = JsonConvert.SerializeObject(point);
50+
var json = JsonSerializer.Serialize(point);
5151

5252
Assert.IsNotNull(json);
5353
Assert.AreEqual(expected, json);
@@ -60,7 +60,7 @@ public void Can_Serialize_DefaultCRS_issue_89()
6060
"{\"type\":\"Point\",\"coordinates\":[34.56,12.34],\"crs\":{\"properties\":{\"name\":\"urn:ogc:def:crs:OGC::CRS84\"},\"type\":\"name\"}}";
6161
var point = new Point(new Position(12.34, 34.56)) { CRS = new NamedCRS("urn:ogc:def:crs:OGC::CRS84") };
6262

63-
var json = JsonConvert.SerializeObject(point);
63+
var json = JsonSerializer.Serialize(point);
6464

6565
Assert.IsNotNull(json);
6666
Assert.AreEqual(expected, json);

src/GeoJSON.Text.Tests/CoordinateReferenceSystem/LinkedCRSTests.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
2+
using System.Text.Json;
23
using GeoJSON.Text.CoordinateReferenceSystem;
34
using GeoJSON.Text.Geometry;
4-
55
using NUnit.Framework;
66

77
namespace GeoJSON.Text.Tests.CoordinateReferenceSystem
@@ -41,7 +41,7 @@ public void Has_Type_Property()
4141
public void Can_Serialize()
4242
{
4343
var collection = new Point(new Position(1, 2, 3)) { CRS = new LinkedCRS(Href) };
44-
var actualJson = JsonConvert.SerializeObject(collection);
44+
var actualJson = JsonSerializer.Serialize(collection);
4545

4646
JsonAssert.Contains("{\"properties\":{\"href\":\"http://localhost\"},\"type\":\"link\"}", actualJson);
4747
}
@@ -50,7 +50,7 @@ public void Can_Serialize()
5050
public void Can_Deserialize_CRS_issue_101()
5151
{
5252
const string pointJson = "{\"type\":\"Point\",\"coordinates\":[2.0,1.0,3.0],\"crs\":{\"properties\":{\"href\":\"http://localhost\"},\"type\":\"link\"}}";
53-
var pointWithCRS = JsonConvert.DeserializeObject<Point>(pointJson);
53+
var pointWithCRS = JsonSerializer.Deserialize<Point>(pointJson);
5454
var linkCRS = pointWithCRS.CRS as LinkedCRS;
5555

5656
Assert.IsNotNull(linkCRS);
@@ -73,14 +73,11 @@ public void Ctor_Throws_ArgumentNullExpection_When_Href_Uri_Is_Null()
7373
[Test]
7474
public void Ctor_Throws_ArgumentExpection_When_Href_Is_Not_Dereferencable_Uri()
7575
{
76-
#if NETCOREAPP1_1
77-
System.Globalization.CultureInfo.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
78-
#else
7976
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
80-
#endif
8177

78+
// Assert that a argument exception is thrown, and that it is for href.
8279
var argumentExpection = Assert.Throws<ArgumentException>(() => { var crs = new LinkedCRS("http://not-a-valid-<>-url"); });
83-
Assert.AreEqual($"must be a dereferenceable URI{Environment.NewLine}Parameter name: href", argumentExpection.Message);
80+
Assert.True(argumentExpection.Message.ToLower().Contains("href"));
8481
}
8582

8683
[Test]

src/GeoJSON.Text.Tests/CoordinateReferenceSystem/NamedCrsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
2+
using System.Text.Json;
23
using GeoJSON.Text.CoordinateReferenceSystem;
34
using GeoJSON.Text.Feature;
4-
55
using NUnit.Framework;
66

77
namespace GeoJSON.Text.Tests.CoordinateReferenceSystem
@@ -32,7 +32,7 @@ public void Has_Name_Property_With_Name()
3232
public void Can_Serialize()
3333
{
3434
var collection = new FeatureCollection() { CRS = new NamedCRS("EPSG:31370") };
35-
var actualJson = JsonConvert.SerializeObject(collection);
35+
var actualJson = JsonSerializer.Serialize(collection);
3636

3737
JsonAssert.Contains("{\"properties\":{\"name\":\"EPSG:31370\"},\"type\":\"name\"}", actualJson);
3838
}

src/GeoJSON.Text.Tests/CoordinateReferenceSystem/UnspecifiedCRSTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using GeoJSON.Text.CoordinateReferenceSystem;
22
using GeoJSON.Text.Feature;
3-
43
using NUnit.Framework;
4+
using System.Text.Json;
55

66
namespace GeoJSON.Text.Tests.CoordinateReferenceSystem
77
{
@@ -21,7 +21,7 @@ public void Can_Serialize_To_Null()
2121
{
2222
var collection = new FeatureCollection { CRS = new UnspecifiedCRS() };
2323
var expectedJson = "{\"type\":\"FeatureCollection\",\"crs\":null,\"features\":[] }";
24-
var actualJson = JsonConvert.SerializeObject(collection);
24+
var actualJson = JsonSerializer.Serialize(collection);
2525

2626
JsonAssert.AreEqual(expectedJson, actualJson);
2727
}
@@ -30,7 +30,7 @@ public void Can_Serialize_To_Null()
3030
public void Can_Deserialize_From_Null()
3131
{
3232
var json = "{\"type\":\"FeatureCollection\",\"crs\":null,\"features\":[] }";
33-
var featureCollection = JsonConvert.DeserializeObject<FeatureCollection>(json);
33+
var featureCollection = JsonSerializer.Deserialize<FeatureCollection>(json);
3434

3535
Assert.IsInstanceOf<UnspecifiedCRS>(featureCollection.CRS);
3636
}

src/GeoJSON.Text.Tests/Feature/FeatureCollectionTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Text.Json;
45
using GeoJSON.Text.Feature;
56
using GeoJSON.Text.Geometry;
6-
77
using NUnit.Framework;
88

99
namespace GeoJSON.Text.Tests.Feature
@@ -25,7 +25,7 @@ public void Can_Deserialize()
2525
{
2626
string json = GetExpectedJson();
2727

28-
var featureCollection = JsonConvert.DeserializeObject<FeatureCollection>(json);
28+
var featureCollection = JsonSerializer.Deserialize<FeatureCollection>(json);
2929

3030
Assert.IsNotNull(featureCollection.Features);
3131
Assert.AreEqual(featureCollection.Features.Count, 3);
@@ -56,13 +56,13 @@ public void FeatureCollectionSerialization()
5656
model.Features.Add(feature);
5757
}
5858

59-
var actualJson = JsonConvert.SerializeObject(model);
59+
var actualJson = JsonSerializer.Serialize(model);
6060

6161
Assert.IsNotNull(actualJson);
6262

6363
Assert.IsFalse(string.IsNullOrEmpty(actualJson));
6464
}
65-
65+
6666
[Test]
6767
public void FeatureCollection_Equals_GetHashCode_Contract()
6868
{
@@ -76,12 +76,12 @@ public void FeatureCollection_Equals_GetHashCode_Contract()
7676
public void Serialized_And_Deserialized_FeatureCollection_Equals_And_Share_HashCode()
7777
{
7878
var leftFc = GetFeatureCollection();
79-
var leftJson = JsonConvert.SerializeObject(leftFc);
80-
var left = JsonConvert.DeserializeObject<FeatureCollection>(leftJson);
79+
var leftJson = JsonSerializer.Serialize(leftFc);
80+
var left = JsonSerializer.Deserialize<FeatureCollection>(leftJson);
8181

8282
var rightFc = GetFeatureCollection();
83-
var rightJson = JsonConvert.SerializeObject(rightFc);
84-
var right = JsonConvert.DeserializeObject<FeatureCollection>(rightJson);
83+
var rightJson = JsonSerializer.Serialize(rightFc);
84+
var right = JsonSerializer.Deserialize<FeatureCollection>(rightJson);
8585

8686
Assert_Are_Equal(left, right);
8787
}
@@ -124,7 +124,7 @@ public void FeatureCollection_Test_IndexOf()
124124
Assert.AreEqual(expectedId, actualId);
125125
Assert.AreEqual(expectedIndex, actualIndex);
126126

127-
Assert.Inconclusive("not supported. the Feature.Id is optional. " +
127+
Assert.Inconclusive("not supported. the Feature.Id is optional. " +
128128
" create a new class that inherits from" +
129129
" Feature and then override Equals and GetHashCode");
130130

0 commit comments

Comments
 (0)