Skip to content
This repository has been archived by the owner on Aug 8, 2020. It is now read-only.

Commit

Permalink
tweaking things for the tests. its coming together.
Browse files Browse the repository at this point in the history
  • Loading branch information
drusellers committed Sep 24, 2010
1 parent d313ad3 commit d583cb5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
24 changes: 21 additions & 3 deletions src/Magnum.Specs/Serialization/YamlSerializerObject_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ public void Should_handle_nested_types()

string text = _serializer.Serialize(parentMessage);

text.ShouldEqual("{Body:{Boo:true,Dub:3.14159,Flt:1.234,Int:47,Long:8675309,Now:2010-03-01}}");
text.ShouldEqual(@"---
Body:
Boo:true
Dub:3.14159
Flt:1.234
Int:47
Long:8675309
Now:2010-03-01
...");
}

[Test, Explicit]
Expand Down Expand Up @@ -73,7 +82,9 @@ public void Should_property_handle_all_types()

string text = _serializer.Serialize(message);

text.ShouldEqual("{Id:" + message.Id.ToString("N") + "}");
text.ShouldEqual(@"---
Id:" + message.Id.ToString("N") + @"
...");
}

[Test]
Expand All @@ -91,7 +102,14 @@ public void Should_property_handle_multiple_types()

string text = _serializer.Serialize(message);

text.ShouldEqual("{Boo:true,Dub:3.14159,Flt:1.234,Int:47,Long:8675309,Now:2010-03-01}");
text.ShouldEqual(@"---
Boo:true
Dub:3.14159
Flt:1.234
Int:47
Long:8675309
Now:2010-03-01
...");
}

private Serializer _serializer;
Expand Down
12 changes: 6 additions & 6 deletions src/Magnum/Serialization/Yaml/YamlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ public class YamlParser
{
public const string DoubleQuoteString = "\"\"";
public const string EmptyMap = "{}";
public const char ItemSeparator = ',';
public const string ItemSeparatorString = ",";
public const char ItemSeparator = ','; //TODO: hmmm \r\n is on oddity
public const string ItemSeparatorString = "\r\n";
public const char ListEnd = ']';
public const string ListEndString = "]";
public const char ListStart = '[';
public const string ListStartString = "[";
public const char MapEnd = '}';
public const string MapEndString = "}";
public const string MapNullValue = "\"\"";
public const char MapSeparator = ':';
public const string MapSeparatorString = ":";
public const char MapStart = '{';
public const string MapStartString = "{";
public const char MapStart = ' ';//TODO: we don't have a start, just an indent increase
public const string MapStartString = "\r\n"; //TODO: chris
public const char MapEnd = ' '; //TODO: we don't have a stop just a dedent
public const string MapEndString = "\r\n";
public const char Quote = '"';
public const string QuoteString = "\"";
public static readonly char[] EscapeChars = new[] {Quote, ItemSeparator, MapStart, MapEnd, ListStart, ListEnd};
Expand Down
5 changes: 4 additions & 1 deletion src/Magnum/Serialization/Yaml/YamlSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ static YamlSerializer()
public void Serialize<T>(T obj, TextWriter writer)
{
YamlTypeSerializer serializer = GetTypeSerializer(typeof(T));

//TODO: add start here
writer.Write("---");
serializer.Serialize(obj, writer.Write);
//TODO: add stop here
writer.Write("...");
}

public string Serialize<T>(T obj)
Expand Down

0 comments on commit d583cb5

Please sign in to comment.