Beispiel #1
0
        public void ParseTest()
        {
            Deserializer deserializer = new Deserializer();

            string noteJson = "{\"guid\": \"002e91a2-2e34-4e2d-bf88-21def49a7705\"," +
                              "\"title\" :\"New Note 6\"," +
                              "\"note-content\" :\"New Note 6\\nDescribe youre note <b>here</b>.\"," +
                              "\"note-content-version\" : 0.2," +
                              "\"last-change-date\" : \"2009-04-19T21:29:23.2197340-07:00\"," +
                              "\"last-metadata-change-date\" : \"2009-04-19T21:29:23.2197340-07:00\"," +
                              "\"create-date\" : \"2008-03-06T13:44:46.4342680-08:00\"," +
                              "\"last-sync-revision\" : 57," +
                              "\"open-on-startup\" : false," +
                              "\"tags\" : [\"tag1\",\"tag2\"]" +
                              "}";

            deserializer.SetInput(noteJson);
            JsonObject noteObj = (JsonObject)deserializer.Deserialize();
            //Assert.AreEqual (57, (int)noteObj["last-sync-revision"]);
            NoteInfo note = NoteInfo.ParseJson(noteObj);

            Assert.AreEqual("002e91a2-2e34-4e2d-bf88-21def49a7705", note.Guid, "GUID");
            Assert.AreEqual("New Note 6\nDescribe youre note <b>here</b>.", note.NoteContent, "NoteContent");
            Assert.AreEqual(0.2, note.NoteContentVersion, "NoteContentVersion");
            Assert.AreEqual("New Note 6", note.Title, "Title");
            Assert.AreEqual(DateTime.Parse("2009-04-19T21:29:23.2197340-07:00"),
                            note.LastChangeDate, "LastChangeDate");
            Assert.AreEqual(DateTime.Parse("2009-04-19T21:29:23.2197340-07:00"),
                            note.LastMetadataChangeDate, "LastMetadataChangeDate");
            Assert.AreEqual(DateTime.Parse("2008-03-06T13:44:46.4342680-08:00"),
                            note.CreateDate, "CreateDate");
            Assert.AreEqual(57, note.LastSyncRevision, "LastSyncRevision");

            Assert.IsTrue(note.OpenOnStartup.HasValue, "OpenOnStartup should have value");
            Assert.IsFalse(note.OpenOnStartup.Value, "OpenOnStartup value");

            Assert.IsNotNull(note.Tags, "Tags should not be null");

            // TODO: Test resourceref,command,lack of guid,nullables,etc,
            //       ApplicationException when missing comma in string, wrong type, etc
        }