diff --git a/src/IIIF/IIIF.Tests/Serialisation/ImageService3SerialiserTests.cs b/src/IIIF/IIIF.Tests/Serialisation/ImageService3SerialiserTests.cs new file mode 100644 index 0000000..004c6e7 --- /dev/null +++ b/src/IIIF/IIIF.Tests/Serialisation/ImageService3SerialiserTests.cs @@ -0,0 +1,38 @@ +using FluentAssertions; +using IIIF.ImageApi.Service; +using IIIF.Serialisation; +using Xunit; + +namespace IIIF.Tests.Serialisation +{ + public class ImageService3SerialiserTests + { + [Fact] + public void WriteJson_OutputsExpected_IfNoProfileOrProfileDescription() + { + // Arrange + var imageService = new ImageService3 { Id = "foo" }; + const string expected = "{\n \"id\": \"foo\",\n \"type\": \"ImageService3\"\n}"; + + // Act + var result = imageService.AsJson().Replace("\r\n", "\n"); + + // Assert + result.Should().Be(expected); + } + + [Fact] + public void WriteJson_OutputsExpected_ProfileOnly() + { + // Arrange + var imageService = new ImageService3 { Id = "foo", Profile = "bar" }; + const string expected = "{\n \"id\": \"foo\",\n \"type\": \"ImageService3\",\n \"profile\": \"bar\"\n}"; + + // Act + var result = imageService.AsJson().Replace("\r\n", "\n"); + + // Assert + result.Should().Be(expected); + } + } +} \ No newline at end of file diff --git a/src/IIIF/IIIF/ImageApi/Service/ImageService3.cs b/src/IIIF/IIIF/ImageApi/Service/ImageService3.cs index b4e8010..7bd473f 100644 --- a/src/IIIF/IIIF/ImageApi/Service/ImageService3.cs +++ b/src/IIIF/IIIF/ImageApi/Service/ImageService3.cs @@ -9,15 +9,10 @@ public class ImageService3 : ResourceBase public const string Image3Context = "http://iiif.io/api/image/3/context.json"; public const string ImageProtocol = "http://iiif.io/api/image"; - public ImageService3() - { - Context = Image3Context; - } - public override string Type => nameof(ImageService3); - [JsonProperty(Order = 3)] - public string Protocol => ImageProtocol; + [JsonProperty(Order = 10)] + public string Protocol { get; set; } [JsonProperty(Order = 11)] public int Width { get; set; } diff --git a/src/IIIF/IIIF/Serialisation/ServiceReferenceConverter.cs b/src/IIIF/IIIF/Serialisation/ServiceReferenceConverter.cs index 36a0e31..f03bda4 100644 --- a/src/IIIF/IIIF/Serialisation/ServiceReferenceConverter.cs +++ b/src/IIIF/IIIF/Serialisation/ServiceReferenceConverter.cs @@ -1,5 +1,4 @@ -using IIIF.Presentation.V2.Serialisation; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace IIIF.Serialisation { diff --git a/src/IIIF/IIIF/Serialisation/SizeConverter.cs b/src/IIIF/IIIF/Serialisation/SizeConverter.cs index abf5a2c..fcda0c1 100644 --- a/src/IIIF/IIIF/Serialisation/SizeConverter.cs +++ b/src/IIIF/IIIF/Serialisation/SizeConverter.cs @@ -1,5 +1,4 @@ -using IIIF.Presentation.V2.Serialisation; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace IIIF.Serialisation { diff --git a/src/IIIF/IIIF/Serialisation/TargetConverter.cs b/src/IIIF/IIIF/Serialisation/TargetConverter.cs index 8489503..067431d 100644 --- a/src/IIIF/IIIF/Serialisation/TargetConverter.cs +++ b/src/IIIF/IIIF/Serialisation/TargetConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using IIIF.Presentation.V3; using IIIF.Utils; using Newtonsoft.Json;