Skip to content

Commit

Permalink
JSON serialization using IsoDateFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Monteiro committed Jul 29, 2012
1 parent e1b27a6 commit 66c8b8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System;
using NUnit.Framework;
using Restfulie.Server.Marshalling.Serializers;
using Restfulie.Server.Marshalling.Serializers.Json;
Expand All @@ -20,12 +20,13 @@ public void SetUp()
[Test]
public void ShouldSerializeAsResource()
{
var resource = new SomeResource {Amount = 123.45, Name = "John Doe"};
var resource = new SomeResource {Amount = 123.45, Name = "John Doe", UpdatedAt = new DateTime(2012,7,29)};

var json = serializer.Serialize(resource);

Assert.That(json.Contains("\"Name\":\"John Doe\""));
Assert.That(json.Contains("\"Amount\":123.45"));
Assert.That(json.Contains("\"UpdatedAt\":\"2012-07-29T00:00:00\""));
}

[Test]
Expand Down
Expand Up @@ -16,7 +16,7 @@ public string Serialize(object resource)
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};

jsonSerializer.Converters.Add(new JavaScriptDateTimeConverter());
jsonSerializer.Converters.Add(new IsoDateTimeConverter());

jsonSerializer.Serialize(textWriter, resource);
return textWriter.ToString();
Expand Down

0 comments on commit 66c8b8d

Please sign in to comment.