Skip to content

Commit

Permalink
all tests success
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Mar 31, 2021
1 parent 98d56bd commit adffa00
Show file tree
Hide file tree
Showing 39 changed files with 535 additions and 1,281 deletions.
10 changes: 0 additions & 10 deletions src/Directory.Build.props

This file was deleted.

6 changes: 6 additions & 0 deletions src/DotNetStac.Test/Collection/CollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public void CanDeserializeSentinel2Sample()
{
var json = GetJson("Collection");

ValidateJson(json);

var item = JsonConvert.DeserializeObject<StacCollection>(json);

Assert.NotNull(item);
Expand Down Expand Up @@ -197,10 +199,14 @@ public void CanSerializeSentinel2Sample()

var actualJson = JsonConvert.SerializeObject(collection);

ValidateJson(actualJson);

Console.WriteLine(actualJson);

var expectedJson = GetJson("Collection");

ValidateJson(expectedJson);

JsonAssert.AreEqual(expectedJson, actualJson);
}

Expand Down
39 changes: 39 additions & 0 deletions src/DotNetStac.Test/Collection/StacRepositoryCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;

namespace Stac.Test.Catalog
{
public class StacRepositoryCollectionTests : TestBase
{
private readonly string currentVersion;

public StacRepositoryCollectionTests(){
var packageJson = httpClient.GetStringAsync("https://raw.githubusercontent.com/radiantearth/stac-spec/master/package.json").GetAwaiter().GetResult();
JObject package = JsonConvert.DeserializeObject<JObject>(packageJson);
currentVersion = package.Value<string>("version");
}

[Fact]
public void CanDeserializeBaseCollectionExample()
{
var json = httpClient.GetStringAsync("https://raw.githubusercontent.com/radiantearth/stac-spec/master/examples/collection.json").GetAwaiter().GetResult();

ValidateJson(json);

StacCollection collection = StacConvert.Deserialize<StacCollection>(json);

Assert.NotNull(collection);

Assert.Equal(currentVersion, collection.StacVersion.ToString());

string collection2json = StacConvert.Serialize(collection);

ValidateJson(collection2json);

JsonAssert.AreEqual(json, collection2json);
}

}
}
1 change: 1 addition & 0 deletions src/DotNetStac.Test/DotNetStac.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<CodeAnalysisRuleSet>$(SolutionDir)StyleCop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0"/>
Expand Down
23 changes: 19 additions & 4 deletions src/DotNetStac.Test/Item/EoExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public void SetAssetBands()
var k3CompleteJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G");
var k3MissingBandsJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G_missing_bands");

StacItem k3MissingBands = JsonConvert.DeserializeObject<StacItem>(k3MissingBandsJson);
ValidateJson(k3CompleteJson);
ValidateJson(k3MissingBandsJson);

StacItem k3MissingBands = StacConvert.Deserialize<StacItem>(k3MissingBandsJson);

EoBandObject eoBandObject = new EoBandObject("MS1", EoBandCommonName.blue)
{
Expand All @@ -33,6 +36,8 @@ public void SetAssetBands()

k3MissingBandsJson = JsonConvert.SerializeObject(k3MissingBands);

ValidateJson(k3MissingBandsJson);

JsonAssert.AreEqual(k3CompleteJson, k3MissingBandsJson);
}

Expand All @@ -41,7 +46,9 @@ public void GetAssetsBands()
{
var k3CompleteJson = GetJson("Item", "GetAssetsBands_K3_20201112193439_45302_18521139_L1G");

StacItem k3complete = JsonConvert.DeserializeObject<StacItem>(k3CompleteJson);
ValidateJson(k3CompleteJson);

StacItem k3complete = StacConvert.Deserialize<StacItem>(k3CompleteJson);

var overviewAssets = k3complete.Assets.Where(a =>
{
Expand Down Expand Up @@ -93,10 +100,14 @@ public void CreateEoExtension()
EoStacExtension eo = new EoStacExtension(item);
eo.CloudCover = 0;

var actualJson = JsonConvert.SerializeObject(item);
var actualJson = StacConvert.Serialize(item);

ValidateJson(actualJson);

var expectedJson = GetJson("Item");

ValidateJson(expectedJson);

JsonAssert.AreEqual(expectedJson, actualJson);
}

Expand All @@ -105,9 +116,13 @@ public void CloneEoItem()
{
var json = GetJson("Item");

ValidateJson(json);

var item = StacConvert.Deserialize<StacItem>(json);

var actualJson = JsonConvert.SerializeObject(item);
var actualJson = StacConvert.Serialize(item);

ValidateJson(actualJson);

JsonAssert.AreEqual(json, actualJson);

Expand Down
27 changes: 19 additions & 8 deletions src/DotNetStac.Test/Item/ItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public void CanDeserializeMinimalSample()
{
var json = GetJson("Item");

var item = JsonConvert.DeserializeObject<StacItem>(json);
ValidateJson(json);

var item = StacConvert.Deserialize<StacItem>(json);

Assert.NotNull(item);

Expand Down Expand Up @@ -83,10 +85,14 @@ public void CanSerializeMinimalSample()
// item.BoundingBoxes = new double[4] { -122.59750209, 37.48803556, -122.2880486, 37.613537207 };
item.BoundingBoxes = item.GetBoundingBoxFromGeometryExtent();

var actualJson = JsonConvert.SerializeObject(item);
var actualJson = StacConvert.Serialize(item);

ValidateJson(actualJson);

var expectedJson = GetJson("Item");

ValidateJson(expectedJson);

JsonAssert.AreEqual(expectedJson, actualJson);
}

Expand All @@ -95,7 +101,9 @@ public void CanManageDates()
{
var json = GetJson("Item");

var item = JsonConvert.DeserializeObject<StacItem>(json);
ValidateJson(json);

var item = StacConvert.Deserialize<StacItem>(json);

Assert.Equal(item.DateTime, new Itenso.TimePeriod.TimeInterval(DateTime.Parse("2016-05-03T13:22:30Z").ToUniversalTime()));
}
Expand All @@ -105,6 +113,8 @@ public void CanDeserializeS2CogSample()
{
var json = GetJson("Item");

ValidateJson(json);

var item = StacConvert.Deserialize<StacItem>(json);

Assert.NotNull(item);
Expand All @@ -118,8 +128,7 @@ public void CanDeserializeS2CogSample()
[Fact]
public void CannotMakeEmptyGeometryItem()
{
Assert.Throws(typeof(ArgumentNullException), () =>
new StacItem(null));
Assert.Throws<ArgumentNullException>(() => new StacItem(null));
}

[Fact]
Expand All @@ -146,11 +155,13 @@ public void GetProperty()

StacItem item = new StacItem("CS3-20160503_132130_04", geometry, properties);

item.SetProperty("test", new string[] {"test1", "test2", "test3"});
item.SetProperty("test", new string[] { "test1", "test2", "test3" });

string json = StacConvert.Serialize(item);

string json = JsonConvert.SerializeObject(item);
ValidateJson(json);

item = JsonConvert.DeserializeObject<StacItem>(json);
item = StacConvert.Deserialize<StacItem>(json);

var array = item.GetProperty<string[]>("test");
}
Expand Down
13 changes: 9 additions & 4 deletions src/DotNetStac.Test/Item/ProcessingExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ public void TestObservableDictionary()
var k3CompleteJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G_software");
var k3MissingSoftwareJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G_missing_software");

StacItem k3MissingSoftware = JsonConvert.DeserializeObject<StacItem>(k3MissingSoftwareJson);
ValidateJson(k3CompleteJson);
ValidateJson(k3MissingSoftwareJson);

StacItem k3MissingSoftware = StacConvert.Deserialize<StacItem>(k3MissingSoftwareJson);

Assert.NotNull(k3MissingSoftware.ProcessingExtension().Software);
Assert.Equal(1, k3MissingSoftware.ProcessingExtension().Software.Count);
Assert.Equal(0, k3MissingSoftware.ProcessingExtension().Software.Count);

k3MissingSoftware.ProcessingExtension().Software.Add("proc_IPF", "2.0.1");

k3MissingSoftwareJson = JsonConvert.SerializeObject(k3MissingSoftware);
Assert.Equal(1, k3MissingSoftware.ProcessingExtension().Software.Count);

k3MissingSoftwareJson = StacConvert.Serialize(k3MissingSoftware);

Assert.True(ValidateJson(k3MissingSoftwareJson));
ValidateJson(k3MissingSoftwareJson);

JsonAssert.AreEqual(k3CompleteJson, k3MissingSoftwareJson);

Expand Down
14 changes: 11 additions & 3 deletions src/DotNetStac.Test/Item/ProjExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ public void SetCoordinateSystem()
{
var k3CompleteJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G");

StacItem k3Complete = JsonConvert.DeserializeObject<StacItem>(k3CompleteJson);
ValidateJson(k3CompleteJson);

StacItem k3Complete = StacConvert.Deserialize<StacItem>(k3CompleteJson);

k3Complete.ProjectionExtension().SetCoordinateSystem(ProjNet.CoordinateSystems.GeocentricCoordinateSystem.WGS84);

string k3newProjJson = JsonConvert.SerializeObject(k3Complete);
string k3newProjJson = StacConvert.Serialize(k3Complete);

var expectedJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G_newproj");

ValidateJson(expectedJson);

JsonAssert.AreEqual(expectedJson, k3newProjJson);

}
Expand All @@ -28,13 +32,17 @@ public void ReadCoordinateSystem()
{
var k3CompleteJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G");

StacItem k3Complete = JsonConvert.DeserializeObject<StacItem>(k3CompleteJson);
ValidateJson(k3CompleteJson);

StacItem k3Complete = StacConvert.Deserialize<StacItem>(k3CompleteJson);

k3Complete.ProjectionExtension().SetCoordinateSystem(4326);

Assert.Equal("GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.01745329251994328, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4326\"]]",
k3Complete.ProjectionExtension().Wkt2);

ValidateJson(StacConvert.Serialize(k3Complete));

}

}
Expand Down
6 changes: 5 additions & 1 deletion src/DotNetStac.Test/Item/SarExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ public void TestFullSar()

stacItem.SarExtension().Required("IW", SarCommonFrequencyBandName.C, new string[2] { "VV", "VH" }, "GRD");

var actualJson = JsonConvert.SerializeObject(stacItem);
var actualJson = StacConvert.Serialize(stacItem);

ValidateJson(actualJson);

var expectedJson = GetJson("Item", "S1A_IW_GRDH_1SDV_20160822T182823_20160822T182848_012717_013FFE_90AF");

ValidateJson(expectedJson);

JsonAssert.AreEqual(expectedJson, actualJson);

}
Expand Down
3 changes: 3 additions & 0 deletions src/DotNetStac.Test/JsonAssert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private static JObject SortProperties(this JObject jObject)

if (avalues != null)
{
if (avalues.Count == 0) continue;
avalues = avalues.SortProperties();
result.Add(property.Name, avalues);
continue;
Expand Down Expand Up @@ -91,5 +92,7 @@ private static JArray SortProperties(this JArray jArray)

return result;
}


}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"stac_version": "1.0.0-rc.1",
"stac_extensions": [],
"type": "Collection",
"id": "COPERNICUS/S2",
"title": "Sentinel-2 MSI: MultiSpectral Instrument, Level-1C",
"description": "Sentinel-2 is a wide-swath, high-resolution, multi-spectral\nimaging mission supporting Copernicus Land Monitoring studies,\nincluding the monitoring of vegetation, soil and water cover,\nas well as observation of inland waterways and coastal areas.\n\nThe Sentinel-2 data contain 13 UINT16 spectral bands representing\nTOA reflectance scaled by 10000. See the [Sentinel-2 User Handbook](https://sentinel.esa.int/documents/247904/685211/Sentinel-2_User_Handbook)\nfor details. In addition, three QA bands are present where one\n(QA60) is a bitmask band with cloud mask information. For more\ndetails, [see the full explanation of how cloud masks are computed.](https://sentinel.esa.int/web/sentinel/technical-guides/sentinel-2-msi/level-1c/cloud-masks)\n\nEach Sentinel-2 product (zip archive) may contain multiple\ngranules. Each granule becomes a separate Earth Engine asset.\nEE asset ids for Sentinel-2 assets have the following format:\nCOPERNICUS/S2/20151128T002653_20151128T102149_T56MNN. Here the\nfirst numeric part represents the sensing date and time, the\nsecond numeric part represents the product generation date and\ntime, and the final 6-character string is a unique granule identifier\nindicating its UTM grid reference (see [MGRS](https://en.wikipedia.org/wiki/Military_Grid_Reference_System)).\n\nFor more details on Sentinel-2 radiometric resoltuon, [see this page](https://earth.esa.int/web/sentinel/user-guides/sentinel-2-msi/resolutions/radiometric).\n",
Expand Down Expand Up @@ -43,22 +43,21 @@
]
}
},

"summaries": {
"datetime": {
"min": "2015-06-23T00:00:00Z",
"max": "2019-07-10T13:44:56Z"
"minimum": "2015-06-23T00:00:00Z",
"maximum": "2019-07-10T13:44:56Z"
},
"platform": ["sentinel-2a","sentinel-2b"],
"constellation": ["sentinel-2"],
"instruments": ["msi"],
"view:off_nadir": {
"min": 0.0,
"max": 100
"minimum": 0.0,
"maximum": 100
},
"view:sun_elevation": {
"min": 6.78,
"max": 89.9
"minimum": 6.78,
"maximum": 89.9
},
"sci:citation": ["Copernicus Sentinel data [Year]"],
"gsd": [10,30,60],
Expand Down
Loading

0 comments on commit adffa00

Please sign in to comment.