Created
March 17, 2012 20:08
-
-
Save wayne-o/2064857 to your computer and use it in GitHub Desktop.
OffsetTests
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
using System; | |
using Newtonsoft.Json; | |
using NUnit.Framework; | |
using NodaTime.Serialization.JsonNet; | |
namespace NodaTime.Serialization.Test.JsonNet | |
{ | |
[TestFixture] | |
public class OffsetTests | |
{ | |
const string expectedJson = "1000000"; | |
[Test] | |
public void JsonNet_Can_Serialize_Offset() | |
{ | |
/* Arrange */ | |
Offset offset = Offset.FromMilliseconds(100); | |
/* Act */ | |
var json = JsonConvert.SerializeObject(offset, new NodaOffsetConverter()); | |
/* Assert */ | |
Assert.AreEqual(expectedJson, json); | |
} | |
[Test] | |
public void JsonNet_Can_Deserialize_Offset() | |
{ | |
/* Arrange */ | |
/* Act */ | |
var offset = JsonConvert.DeserializeObject<Offset>(expectedJson, new NodaOffsetConverter()); | |
/* Assert */ | |
var expectedOffset = Offset.FromMilliseconds(100); | |
Assert.AreEqual(expectedOffset, offset); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment