Exemplo n.º 1
0
        public void BenchmarkNoteStorage()
        {
            var local_storage = new DiskStorage ("../../tmpstorage");
            var sample_notes = TestBase.GetSampleNotes ();
            var manifest = new SyncManifest ();
            var engine = new Engine (local_storage);
            sample_notes.ForEach(n => engine.SaveNote (n));

            var sync_client = new FilesystemSyncClient (engine, manifest);
            var access_token = WebSyncServer.PerformFastTokenExchange (listenUrl, "testuser", "testpass");
            var sync_server = new WebSyncServer (listenUrl, access_token);

            Action benchmark = () => new SyncManager (sync_client, sync_server).DoSync ();
            DbBenchmarks.RunBenchmark ("initial sync with 100 times no change at all", benchmark, 100);
        }
Exemplo n.º 2
0
        private static void ProcessDirectory(string targetDirectory, Engine appEngine)
        {
            DiskStorage noteStorage = new DiskStorage (targetDirectory);
            Engine noteEngine = new Engine (noteStorage);
            Dictionary<string,Note> notes = new Dictionary<string,Note>();

            try {
                notes = noteEngine.GetNotes ();
            } catch (ArgumentException) {
                Console.WriteLine ("Found an exception with {0}",targetDirectory);
            }

            foreach (Note note in notes.Values) {

                Note newNote = appEngine.NewNote ();
                newNote.ChangeDate = note.ChangeDate;
                newNote.CreateDate = note.CreateDate;
                newNote.CursorPosition = note.CursorPosition;
                newNote.Height = note.Height;
                newNote.MetadataChangeDate = note.MetadataChangeDate;
                newNote.Notebook = note.Notebook;
                newNote.OpenOnStartup = note.OpenOnStartup;
                newNote.SelectionBoundPosition = note.SelectionBoundPosition;
                newNote.Tags = note.Tags;
                newNote.Text = note.Text;
                newNote.Title = note.Title;
                newNote.Width = note.Width;
                newNote.X = note.X;
                newNote.Y = note.Y;
                appEngine.SaveNote (newNote, false);

                Console.WriteLine ("Imported the Note {0}",newNote.Title);
            }

            string [] subdirectoryEntries = System.IO.Directory.GetDirectories(targetDirectory);
            foreach(string subdirectory in subdirectoryEntries)
                ProcessDirectory(subdirectory, appEngine);
        }
Exemplo n.º 3
0
        public void Init()
        {
            IPortableIoC container = new PortableIoc ();
            container.Register<DiskStorage> (c => {
                return new DiskStorage ("../../test_notes/proper_notes") {
                    Logger = new ConsoleLogger ()
                };
            });
            diskStorage = container.Resolve<DiskStorage> ();

            engine = new Engine (diskStorage);
            // get a new note instance
            note = engine.NewNote ();
            note.Title = "Unit Test Note";
            note.Text = "Unit test note by NewNote() method";
            engine.SaveNote (note);
            NOTE_PATH = Path.Combine ("../../test_notes/proper_notes", Utils.GetNoteFileNameFromURI (note));
        }
Exemplo n.º 4
0
 public void Init()
 {
     //TODO: The storage instance needs swapping with a stub/mock!
     DiskStorage.Instance.SetPath ("../../test_notes/proper_notes");
     engine = new Engine (DiskStorage.Instance);
     // get a new note instance
     note = engine.NewNote ();
     note.Title = "Unit Test Note";
     note.Text = "Unit test note by NewNote() method";
     engine.SaveNote (note);
     NOTE_PATH = Path.Combine ("../../test_notes/proper_notes", Utils.GetNoteFileNameFromURI (note));
 }