Skip to content

Feature/change project naming #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
name: Build and Tests
name: 'Build and Test'

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
Build:

runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src

env:
VSTEST_CONNECTION_TIMEOUT: 900

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: Install dependencies
run: dotnet restore
- name: Build solution
run: dotnet build -c Release --no-restore /p:Version=1.2.3.4
- name: Test
run: dotnet test -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ../coverage/
flags: unittests

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/


*.opencover.xml
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[![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)


# GetJson.Text
.Net library for GeoJSON types & corresponding System.TExt.Json (de)serializers
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using GeoJSON.Text.CoordinateReferenceSystem;
using GeoJSON.Text.Feature;
using GeoJSON.Text.Geometry;

using NUnit.Framework;
using System.Text.Json;

namespace GeoJSON.Text.Tests.CoordinateReferenceSystem
{
Expand All @@ -14,7 +14,7 @@ public void Can_Serialize_Does_Not_Output_Crs_Property()
{
var collection = new FeatureCollection();

var json = JsonConvert.SerializeObject(collection);
var json = JsonSerializer.Serialize(collection);

Assert.IsTrue(!json.Contains("\"crs\""));
}
Expand All @@ -23,8 +23,8 @@ public void Can_Serialize_Does_Not_Output_Crs_Property()
public void Can_Deserialize_When_Json_Does_Not_Contain_Crs_Property()
{
var json = "{\"coordinates\":[90.65464646,53.2455662,200.4567],\"type\":\"Point\"}";

var point = JsonConvert.DeserializeObject<Point>(json);
var point = JsonSerializer.Deserialize<Point>(json);

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

var point = JsonConvert.DeserializeObject<Point>(json);
var point = JsonSerializer.Deserialize<Point>(json);

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

var json = JsonConvert.SerializeObject(point);
var json = JsonSerializer.Serialize(point);

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

var json = JsonConvert.SerializeObject(point);
var json = JsonSerializer.Serialize(point);

Assert.IsNotNull(json);
Assert.AreEqual(expected, json);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text.Json;
using GeoJSON.Text.CoordinateReferenceSystem;
using GeoJSON.Text.Geometry;

using NUnit.Framework;

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

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

Assert.IsNotNull(linkCRS);
Expand All @@ -73,14 +73,11 @@ public void Ctor_Throws_ArgumentNullExpection_When_Href_Uri_Is_Null()
[Test]
public void Ctor_Throws_ArgumentExpection_When_Href_Is_Not_Dereferencable_Uri()
{
#if NETCOREAPP1_1
System.Globalization.CultureInfo.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
#else
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
#endif

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

[Test]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text.Json;
using GeoJSON.Text.CoordinateReferenceSystem;
using GeoJSON.Text.Feature;

using NUnit.Framework;

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

JsonAssert.Contains("{\"properties\":{\"name\":\"EPSG:31370\"},\"type\":\"name\"}", actualJson);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using GeoJSON.Text.CoordinateReferenceSystem;
using GeoJSON.Text.Feature;

using NUnit.Framework;
using System.Text.Json;

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

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

Assert.IsInstanceOf<UnspecifiedCRS>(featureCollection.CRS);
}
Expand Down
18 changes: 9 additions & 9 deletions src/GeoJSON.Text.Tests/Feature/FeatureCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using GeoJSON.Text.Feature;
using GeoJSON.Text.Geometry;

using NUnit.Framework;

namespace GeoJSON.Text.Tests.Feature
Expand All @@ -25,7 +25,7 @@ public void Can_Deserialize()
{
string json = GetExpectedJson();

var featureCollection = JsonConvert.DeserializeObject<FeatureCollection>(json);
var featureCollection = JsonSerializer.Deserialize<FeatureCollection>(json);

Assert.IsNotNull(featureCollection.Features);
Assert.AreEqual(featureCollection.Features.Count, 3);
Expand Down Expand Up @@ -56,13 +56,13 @@ public void FeatureCollectionSerialization()
model.Features.Add(feature);
}

var actualJson = JsonConvert.SerializeObject(model);
var actualJson = JsonSerializer.Serialize(model);

Assert.IsNotNull(actualJson);

Assert.IsFalse(string.IsNullOrEmpty(actualJson));
}

[Test]
public void FeatureCollection_Equals_GetHashCode_Contract()
{
Expand All @@ -76,12 +76,12 @@ public void FeatureCollection_Equals_GetHashCode_Contract()
public void Serialized_And_Deserialized_FeatureCollection_Equals_And_Share_HashCode()
{
var leftFc = GetFeatureCollection();
var leftJson = JsonConvert.SerializeObject(leftFc);
var left = JsonConvert.DeserializeObject<FeatureCollection>(leftJson);
var leftJson = JsonSerializer.Serialize(leftFc);
var left = JsonSerializer.Deserialize<FeatureCollection>(leftJson);

var rightFc = GetFeatureCollection();
var rightJson = JsonConvert.SerializeObject(rightFc);
var right = JsonConvert.DeserializeObject<FeatureCollection>(rightJson);
var rightJson = JsonSerializer.Serialize(rightFc);
var right = JsonSerializer.Deserialize<FeatureCollection>(rightJson);

Assert_Are_Equal(left, right);
}
Expand Down Expand Up @@ -124,7 +124,7 @@ public void FeatureCollection_Test_IndexOf()
Assert.AreEqual(expectedId, actualId);
Assert.AreEqual(expectedIndex, actualIndex);

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

Expand Down
Loading