Пример #1
0
 public void GetNotes_NotesExist_ReturnsNotes()
 {
     IStorage storage = new DiskStorage (NOTE_FOLDER_PROPER_NOTES);
     Dictionary<string, Note> notes = storage.GetNotes ();
     Assert.IsNotNull (notes);
     Assert.IsTrue (notes.Count > 0);
 }
Пример #2
0
 public void GetNotes_NoteFolderDoesNotExist_ReturnsNone()
 {
     IStorage storage = new DiskStorage (NOTE_FOLDER_INVALID);
     Dictionary<string, Note> notes = storage.GetNotes ();
     Assert.IsNotNull (notes);
     Assert.IsTrue (notes.Count == 0);
 }
Пример #3
0
        public static void AddDummyUserIfRequired(Funq.Container container)
        {
            // create a dummy user
            var fac = container.Resolve<IDbConnectionFactory> ();
            using (var db = fac.OpenDbConnection ()) {

                if (db.FirstOrDefault<DBUser> (u => u.Username == "dummy") == null) {

                    var user = new DBUser ();
                    user.Username = "******";
                    user.CreateCryptoFields ("foobar123");
                    user.FirstName = "John Dummy";
                    user.LastName = "Doe";
                    user.AdditionalData  = "Dummy user that is created when in development mode";
                    user.IsActivated = true;
                    user.IsVerified = true;
                    user.Manifest.LastSyncRevision = 0;
                    user.EmailAddress = "*****@*****.**";
                    db.Insert<DBUser> (user);
                    // insert some sample notes
                    var f = container.Resolve<DbStorageFactory> ();
                    var key = user.GetPlaintextMasterKey ("foobar123");
                    var r = new RequestingUser {
                        Username = "******",
                        EncryptionMasterKey = key.ToHexString ()
                    };
                    // populate with note test cases taken from Tomdroid
                    // these notes will fail Tomboy...
                    using (var storage = f.GetDbStorage (r)) {
                        var sample_notes = new DiskStorage ("../../../sample_notes/");
                        sample_notes.GetNotes ().Values.ToList ().ForEach (n => storage.SaveNote (n));
                    }

                }
            }
        }
Пример #4
0
 public void GetNotes_NoteExistsWithSpecificKey_ReturnsNoteWithSpecificKey()
 {
     IStorage storage = new DiskStorage (NOTE_FOLDER_PROPER_NOTES);
     Dictionary<string, Note> notes = storage.GetNotes ();
     Assert.IsTrue (notes.ContainsKey ("note://tomboy/90d8eb70-989d-4b26-97bc-ba4b9442e51f"));
 }
Пример #5
0
 public void GetNotes_NoteDoesNotExistWithSpecificKey_DoesNotReturnNoteWithSpecificKey()
 {
     IStorage storage = new DiskStorage (NOTE_FOLDER_PROPER_NOTES);
     Dictionary<string, Note> notes = storage.GetNotes ();
     Assert.IsFalse (notes.ContainsKey ("not-a-key"));
 }