public void ConvertFromDTOWithTags() { var dto_note = new DTONote (); dto_note.Tags = new string[] { "school", "shopping", "fun" }; var tomboy_note = dto_note.ToTomboyNote (); foreach (string tag in dto_note.Tags) { Assert.Contains (tag, tomboy_note.Tags.Keys); } }
public static DTONote ToDTONote(this DBNote db) { var dto = new DTONote (); dto.Guid = db.Guid; dto.Title = db.Title; dto.Text = db.Text; dto.Tags = db.Tags; // dates dto.ChangeDate = db.ChangeDate; dto.MetadataChangeDate = db.MetadataChangeDate; dto.CreateDate = db.CreateDate; dto.OpenOnStartup = db.OpenOnStartup; dto.Pinned = db.Pinned; return dto; }
public void ConvertFromDTONoteToTomboyNote() { var dto_note = new DTONote (); dto_note.Title = "This is a sample note"; dto_note.Text = "This is some sample text"; dto_note.ChangeDate = DateTime.Now.ToString (Tomboy.Writer.DATE_TIME_FORMAT); dto_note.MetadataChangeDate = DateTime.Now.ToString (Tomboy.Writer.DATE_TIME_FORMAT); dto_note.CreateDate = DateTime.Now.ToString (Tomboy.Writer.DATE_TIME_FORMAT); var tomboy_note = dto_note.ToTomboyNote (); Assert.AreEqual (tomboy_note.Title, dto_note.Title); Assert.AreEqual (tomboy_note.Text, dto_note.Text); Assert.AreEqual (tomboy_note.ChangeDate, DateTime.Parse (dto_note.ChangeDate).ToUniversalTime ()); Assert.AreEqual (tomboy_note.CreateDate, DateTime.Parse (dto_note.CreateDate).ToUniversalTime ()); Assert.AreEqual (tomboy_note.MetadataChangeDate, DateTime.Parse (dto_note.MetadataChangeDate).ToUniversalTime ()); var tag_intersection = dto_note.Tags.Intersect (tomboy_note.Tags.Keys); Assert.AreEqual (dto_note.Tags.Count (), tag_intersection.Count ()); }
// Tomboy.Note -> DTONote public static DTONote ToDTONote(this Tomboy.Note tomboy_note) { DTONote dto_note = new DTONote (); // using ServiceStack simple auto mapper dto_note.PopulateWith (tomboy_note); // copy over tags dto_note.Tags = tomboy_note.Tags.Keys.ToArray (); // correctly format the DateTime to strings dto_note.CreateDate = tomboy_note.CreateDate.ToString (XmlSettings.DATE_TIME_FORMAT); dto_note.ChangeDate = tomboy_note.ChangeDate.ToString (XmlSettings.DATE_TIME_FORMAT); dto_note.MetadataChangeDate = tomboy_note.MetadataChangeDate.ToString (XmlSettings.DATE_TIME_FORMAT); return dto_note; }