-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from signnow/feature/thumbnails
Feature | Thumbnails
- Loading branch information
Showing
14 changed files
with
226 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Bogus; | ||
using SignNow.Net.Model; | ||
|
||
namespace SignNow.Net.Test.FakeModels | ||
{ | ||
/// <summary> | ||
/// Fake model for <see cref="Thumbnail"/> | ||
/// </summary> | ||
public class ThumbnailFaker : Faker<Thumbnail> | ||
{ | ||
private const string DefaultThumbnailText = "signNow test"; | ||
|
||
public ThumbnailFaker() | ||
{ | ||
Rules((f, o) => | ||
{ | ||
o.Small = new Uri(f.Image.PlaceholderUrl(85, 110, DefaultThumbnailText)); | ||
o.Medium = new Uri(f.Image.PlaceholderUrl(340, 440, DefaultThumbnailText)); | ||
o.Large = new Uri(f.Image.PlaceholderUrl(890, 1151, DefaultThumbnailText)); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Newtonsoft.Json; | ||
using SignNow.Net.Model; | ||
using SignNow.Net.Test.FakeModels; | ||
|
||
namespace UnitTests | ||
{ | ||
[TestClass] | ||
public class ThumbnailTest | ||
{ | ||
[TestMethod] | ||
public void ShouldDeserializeFromJson() | ||
{ | ||
const string Json = @"{ | ||
""small"": ""https://api.signnow.com/document/a09b26feeba7ce70228afe6290f4445700b6f349/thumbnail?size=small"", | ||
""medium"":""https://api.signnow.com/document/a09b26feeba7ce70228afe6290f4445700b6f349/thumbnail?size=medium"", | ||
""large"": ""https://api.signnow.com/document/a09b26feeba7ce70228afe6290f4445700b6f349/thumbnail?size=large"" | ||
}"; | ||
|
||
var actual = JsonConvert.DeserializeObject<Thumbnail>(Json); | ||
|
||
Assert.AreEqual( | ||
"https://api.signnow.com/document/a09b26feeba7ce70228afe6290f4445700b6f349/thumbnail?size=small", | ||
actual.Small.AbsoluteUri); | ||
Assert.AreEqual("?size=small", actual.Small.Query); | ||
Assert.AreEqual("?size=medium", actual.Medium.Query); | ||
Assert.AreEqual("?size=large", actual.Large.Query); | ||
} | ||
|
||
[TestMethod] | ||
public void ShouldBeSerializable() | ||
{ | ||
var model = new ThumbnailFaker().Generate(); | ||
|
||
var actual = JsonConvert.SerializeObject(model); | ||
|
||
StringAssert.Contains(actual, "small"); | ||
StringAssert.Contains(actual, "medium"); | ||
StringAssert.Contains(actual, "large"); | ||
StringAssert.Contains(actual, "https://via.placeholder.com"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using SignNow.Net.Internal.Helpers.Converters; | ||
|
||
namespace SignNow.Net.Model | ||
{ | ||
/// <summary> | ||
/// Represents thumbnails of the document. | ||
/// </summary> | ||
public class Thumbnail | ||
{ | ||
/// <summary> | ||
/// Uri for small document preview image size. | ||
/// A4 (210 x 297 mm) ~ 85 x 110 px @ 10 ppi | ||
/// </summary> | ||
[JsonProperty("small")] | ||
[JsonConverter(typeof(StringToUriJsonConverter))] | ||
public Uri Small { get; internal set; } | ||
|
||
/// <summary> | ||
/// Uri for medium document preview image size | ||
/// A4 (210 x 297 mm) ~ 340 x 440 px @ 40 ppi | ||
/// </summary> | ||
[JsonProperty("medium")] | ||
[JsonConverter(typeof(StringToUriJsonConverter))] | ||
public Uri Medium { get; internal set; } | ||
|
||
/// <summary> | ||
/// Uri for large document preview image size. | ||
/// A4 (210 x 297 mm) ~ 890 x 1151 px @ 104 ppi | ||
/// </summary> | ||
[JsonProperty("large")] | ||
[JsonConverter(typeof(StringToUriJsonConverter))] | ||
public Uri Large { get; internal set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.