Skip to content

Instantly share code, notes, and snippets.

@wayne-o
Created March 17, 2012 20:08
Show Gist options
  • Save wayne-o/2064857 to your computer and use it in GitHub Desktop.
Save wayne-o/2064857 to your computer and use it in GitHub Desktop.
OffsetTests
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