mirror of https://github.com/LordMike/TMDbLib.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
using System;
|
|
using Newtonsoft.Json;
|
|
using TMDbLib.Objects.Authentication;
|
|
using TMDbLib.Utilities.Converters;
|
|
using TMDbLibTests.Helpers;
|
|
using TMDbLibTests.JsonHelpers;
|
|
using Xunit;
|
|
|
|
namespace TMDbLibTests.UtilityTests
|
|
{
|
|
public class CustomDatetimeFormatConverterTest : TestBase
|
|
{
|
|
[Fact]
|
|
public void CustomDatetimeFormatConverter_Data()
|
|
{
|
|
JsonSerializerSettings settings = new JsonSerializerSettings();
|
|
settings.Converters.Add(new CustomDatetimeFormatConverter());
|
|
|
|
Token original = new Token();
|
|
original.ExpiresAt = DateTime.UtcNow.Date;
|
|
original.ExpiresAt = original.ExpiresAt.AddMilliseconds(-original.ExpiresAt.Millisecond);
|
|
|
|
string json = JsonConvert.SerializeObject(original, settings);
|
|
Token result = JsonConvert.DeserializeObject<Token>(json, settings);
|
|
|
|
Assert.Equal(original.ExpiresAt, result.ExpiresAt);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tests the CustomDatetimeFormatConverter
|
|
/// </summary>
|
|
[Fact]
|
|
public void TestCustomDatetimeFormatConverter()
|
|
{
|
|
Token token = Config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
|
|
|
DateTime low = DateTime.UtcNow.AddHours(-2);
|
|
DateTime high = DateTime.UtcNow.AddHours(2);
|
|
|
|
Assert.InRange(token.ExpiresAt, low, high);
|
|
}
|
|
}
|
|
}
|