Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from Mehigh17/develop
Browse files Browse the repository at this point in the history
Fix minor incosistencies with the WPS standard
  • Loading branch information
Mehigh17 authored Aug 29, 2019
2 parents 26d8786 + 5e7789d commit aff4604
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
14 changes: 9 additions & 5 deletions src/Wps/Wps.Client.Tests/ModelSerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void SerializeValueRange_ValidRangeGiven_ShouldPass()
[Fact]
public void SerializeDataInput_ValidInputGiven_ShouldPass()
{
const string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?><Input id=""test-id"" xmlns=""http://www.opengis.net/wps/2.0""><wps:Data xmlns:wps=""http://www.opengis.net/wps/2.0""><LiteralValue xmlns=""http://www.opengis.net/wps/2.0"">105</LiteralValue></wps:Data><wps:Reference xmlns:ows=""http://www.opengis.net/ows/2.0"" xmlns:xli=""http://www.w3.org/1999/xlink"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xli:href=""test"" schema=""test-schema"" xmlns:wps=""http://www.opengis.net/wps/2.0"" /></Input>";
const string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?><Input id=""test-id"" xmlns=""http://www.opengis.net/wps/2.0""><wps:Data mimeType=""test mime type"" encoding=""test encoding"" schema=""test schema"" xmlns:wps=""http://www.opengis.net/wps/2.0"">test string</wps:Data><wps:Reference xmlns:ows=""http://www.opengis.net/ows/2.0"" xmlns:xli=""http://www.w3.org/1999/xlink"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xli:href=""test"" schema=""test-schema"" xmlns:wps=""http://www.opengis.net/wps/2.0"" /></Input>";

// Remove white spaces and new line characters for XML comparison.
var trimmedExpectedXml = Regex.Replace(expectedXml, @"\s+", string.Empty);
Expand All @@ -150,10 +150,14 @@ public void SerializeDataInput_ValidInputGiven_ShouldPass()
Href = "test",
Schema = "test-schema"
},
Data = new LiteralDataValue
{
Value = 105.ToString(CultureInfo.InvariantCulture)
}
//Data = new LiteralDataValue
//{
// Value = 105.ToString(CultureInfo.InvariantCulture)
//},
Data = "test string",
MimeType = "test mime type",
Schema = "test schema",
Encoding = "test encoding"
};

var resultXml = _serializer.Serialize(dataInput);
Expand Down
1 change: 0 additions & 1 deletion src/Wps/Wps.Client.Tests/WpsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Wps.Client.Models.Requests;
using Wps.Client.Services;
using Xunit;
using Xunit.Sdk;

namespace Wps.Client.Tests
{
Expand Down
19 changes: 18 additions & 1 deletion src/Wps/Wps.Client/Models/Execution/DataInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@

namespace Wps.Client.Models.Execution
{
/// <summary>
/// The data input model used for the execution requests. If the data is of type <see cref="string"/> it will be copied inside the data tags as is with no further serialization.
/// </summary>
[XmlRoot("Input", Namespace = ModelNamespaces.Wps)]
public class DataInput : IXmlSerializable
{

public string MimeType { get; set; }
public string Encoding { get; set; }
public string Schema { get; set; }

public string Identifier { get; set; }
public object Data { get; set; }
public ResourceReference Reference { get; set; }
Expand All @@ -34,7 +41,17 @@ public void WriteXml(XmlWriter writer)
if (Data != null)
{
writer.WriteStartElement("wps", "Data", ModelNamespaces.Wps);
writer.WriteRaw(xmlSerializer.Serialize(Data, true));
if (!string.IsNullOrEmpty(MimeType)) writer.WriteAttributeString("mimeType", MimeType);
if (!string.IsNullOrEmpty(Encoding)) writer.WriteAttributeString("encoding", Encoding);
if (!string.IsNullOrEmpty(Schema)) writer.WriteAttributeString("schema", Schema);
if (Data is string s)
{
writer.WriteRaw(s);
}
else
{
writer.WriteRaw(xmlSerializer.Serialize(Data, true));
}
writer.WriteEndElement();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Wps/Wps.Client/Wps.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageId>Wps.Net</PackageId>
<Version>1.0.1</Version>
<Version>1.0.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit aff4604

Please sign in to comment.