Esempio n. 1
0
        public void ConvertBackAndForth()
        {
            var tn1 = new Note () {
                Title = "This is my Title with Umlauts: äöü",
                Text = "This is my note body text.",
                CreateDate = DateTime.Now - new TimeSpan (365, 0, 0, 0),
                MetadataChangeDate = DateTime.Now,
                ChangeDate = DateTime.Now - new TimeSpan (14, 0, 0, 0)

                // TODO check why OpenOnStartup is of type string in Tomboy
                //OpenOnStartup = "true"
            };

            var dto_note = tn1.ToDTONote ();
            var tn2 = dto_note.ToTomboyNote ();

            // notes should be identical
            Assert.AreEqual (tn1.Guid, tn2.Guid);
            Assert.AreEqual (tn1.Uri, tn2.Uri);
            Assert.AreEqual (tn1.Title, tn2.Title);
            Assert.AreEqual (tn1.Text, tn2.Text);

            Assert.AreEqual (tn1.ChangeDate, tn2.ChangeDate);
            Assert.AreEqual (tn1.MetadataChangeDate, tn2.MetadataChangeDate);
            Assert.AreEqual (tn1.CreateDate, tn2.CreateDate);

            Assert.AreEqual (tn1.OpenOnStartup, tn2.OpenOnStartup);

            Assert.AreEqual (tn1.Tags.Keys, tn2.Tags.Keys);
        }
Esempio n. 2
0
        public override void SaveNote(Note note)
        {
            var db_note = note.ToDTONote ().ToDBNote (Username);

            db_note.EncryptedKey = GetEncryptedNoteKey (db_note);
            EncryptNoteBody (db_note);
            base.SaveDBNote (db_note);
        }
Esempio n. 3
0
        public void SaveNote(Note note)
        {
            var dbNote = note.ToDTONote ().ToDBNote (User);

            // unforunately, we can't know if that note already exist
            // so we delete any previous incarnations of that note and
            // re-insert
            db.Delete<DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey);
            db.Insert (dbNote);
        }
Esempio n. 4
0
        public void SaveNote(Note note)
        {
            var dbNote = note.ToDTONote ().ToDBNote ();
            dbNote.Username = Username;

            // unforunately, we can't know if that note already exist
            // so we delete any previous incarnations of that note and
            // re-insert
            db.Delete<DBNote> (n => n.Username == Username && n.Guid == dbNote.Guid);
            db.Insert (dbNote);
        }
Esempio n. 5
0
        public void DeleteNote(Note note)
        {
            var dbNote = note.ToDTONote ().ToDBNote (User);

            if (UseHistory) {
                var archived_note = new DBArchivedNote ().PopulateWith(dbNote);
                if (Manifest.NoteRevisions.ContainsKey (note.Guid)) {
                    archived_note.LastSyncRevision = Manifest.NoteRevisions[note.Guid];
                }
                var stored_note = db.FirstOrDefault<DBArchivedNote> (n => n.CompoundPrimaryKey == archived_note.CompoundPrimaryKey);
                // if that revision already exists, do not store
                if (stored_note == null)
                    db.Insert<DBArchivedNote> (archived_note);
            }

            db.Delete<DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey);
        }
Esempio n. 6
0
 public void DeleteNote(Note note)
 {
     var dbNote = note.ToDTONote ().ToDBNote (User);
     db.Delete<DBNote> (n => n.CompoundPrimaryKey == dbNote.CompoundPrimaryKey);
 }
Esempio n. 7
0
        public void ConvertFromTomboyNoteToDTO()
        {
            var tomboy_note = new Note ();
            tomboy_note.Title = "This is a sample note";
            tomboy_note.Text = "This is some sample text";

            tomboy_note.ChangeDate = DateTime.Now;
            tomboy_note.CreateDate = DateTime.Now;
            tomboy_note.MetadataChangeDate = DateTime.Now;

            var dto_note = tomboy_note.ToDTONote ();

            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 ());

            Assert.AreEqual (tomboy_note.Guid, dto_note.Guid);

            var tag_intersection = dto_note.Tags.Intersect (tomboy_note.Tags.Keys);
            Assert.AreEqual (dto_note.Tags.Count (), tag_intersection.Count ());
        }
Esempio n. 8
0
        public void ConvertUriTests()
        {
            var tomboy_note = new Note ();

            tomboy_note.CreateDate = DateTime.Now;
            tomboy_note.ChangeDate = DateTime.Now;
            tomboy_note.MetadataChangeDate = DateTime.Now;

            var dto_note = tomboy_note.ToDTONote ();

            Assert.That (!string.IsNullOrEmpty (dto_note.Guid));

            Assert.AreEqual (tomboy_note.Guid, dto_note.Guid);
            Assert.That (tomboy_note.Uri.Contains (dto_note.Guid));
            Assert.That (tomboy_note.Uri.Contains (tomboy_note.Guid));

            var tomboy_note_2 = dto_note.ToTomboyNote ();
            Assert.AreEqual (tomboy_note.Guid, tomboy_note_2.Guid);
            Assert.AreEqual (tomboy_note.Uri, tomboy_note_2.Uri);
        }
Esempio n. 9
0
        public void ConvertToDTOWithTags()
        {
            var tomboy_note = new Note ();
            tomboy_note.Tags.Add ("school", new Tag ("school"));
            tomboy_note.Tags.Add ("shopping", new Tag ("shopping"));
            tomboy_note.Tags.Add ("fun", new Tag ("fun"));

            var dto_note = tomboy_note.ToDTONote ();

            foreach (string tag in tomboy_note.Tags.Keys) {
                Assert.Contains (tag, dto_note.Tags);
            }
        }
Esempio n. 10
0
 public virtual void SaveNote(Note note)
 {
     var db_note = note.ToDTONote ().ToDBNote (this.Username);
     SaveDBNote (db_note);
 }