Skip to content

Commit

Permalink
Add imageService3 serialisation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldgray committed May 12, 2022
1 parent 7ba7c90 commit af11605
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
38 changes: 38 additions & 0 deletions src/IIIF/IIIF.Tests/Serialisation/ImageService3SerialiserTests.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
9 changes: 2 additions & 7 deletions src/IIIF/IIIF/ImageApi/Service/ImageService3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 1 addition & 2 deletions src/IIIF/IIIF/Serialisation/ServiceReferenceConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using IIIF.Presentation.V2.Serialisation;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace IIIF.Serialisation
{
Expand Down
3 changes: 1 addition & 2 deletions src/IIIF/IIIF/Serialisation/SizeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using IIIF.Presentation.V2.Serialisation;
using Newtonsoft.Json;
using Newtonsoft.Json;

namespace IIIF.Serialisation
{
Expand Down
1 change: 0 additions & 1 deletion src/IIIF/IIIF/Serialisation/TargetConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using IIIF.Presentation.V3;
using IIIF.Utils;
using Newtonsoft.Json;
Expand Down

0 comments on commit af11605

Please sign in to comment.