public void JsonResult_SerializeData_Good() { var data = new RowSetCollectionData(); var rowset1 = new RowSetData(); data.AddRowSet(rowset1); var row11 = new AtomCollectionData(); row11.AddAtom(new AtomData(Name11, StringValue)); rowset1.AddRow(row11); var row12 = new AtomCollectionData(); row12.AddAtom(new AtomData(Name11, DecimalValue)); rowset1.AddRow(row12); var row13 = new AtomCollectionData(); row13.AddAtom(new AtomData(Name11, IntegerValue)); rowset1.AddRow(row13); var rowset2 = new RowSetData(); data.AddRowSet(rowset2); var row21 = new AtomCollectionData(); row21.AddAtom(new AtomData(Name21, StringValue)); row21.AddAtom(new AtomData(Name22, DecimalValue)); row21.AddAtom(new AtomData(Name23, IntegerValue)); rowset2.AddRow(row21); using (var writer = new StringWriter()) { _serializer.SerializeData(writer, data); var text = writer.ToString(); Console.WriteLine(text); Assert.AreEqual("{:[[{:}{:}{:}][{:::}]]}", Skeletonize(text, "[]{}:")); Assert.AreEqual(1, GetOccurrenceCount(DataName, text)); Assert.AreEqual(0, GetOccurrenceCount(ErrorName, text)); Assert.AreEqual(3, GetOccurrenceCount(Name11, text)); Assert.AreEqual(1, GetOccurrenceCount(Name21, text)); Assert.AreEqual(1, GetOccurrenceCount(Name22, text)); Assert.AreEqual(1, GetOccurrenceCount(Name23, text)); Assert.AreEqual(2, GetOccurrenceCount(StringValue, text)); Assert.AreEqual(2, GetOccurrenceCount(DecimalValue.ToString(CultureInfo.InvariantCulture), text)); Assert.AreEqual(2, GetOccurrenceCount(IntegerValue.ToString(CultureInfo.InvariantCulture), text)); } }
public void JsonResult_SerializeData_Bad() { var data = new RowSetCollectionData(); var rowset = new RowSetData(); data.AddRowSet(rowset); var row1 = new AtomCollectionData(); row1.AddAtom(new AtomData()); rowset.AddRow(row1); using (var writer = new StringWriter()) { _serializer.SerializeData(writer, data); var text = writer.ToString(); Console.WriteLine(text); Assert.AreEqual(1, GetOccurrenceCount(ErrorName, text)); } }