Пример #1
0
        public Form1()
        {
            InitializeComponent();
            // create IMRUItemStorage implementation using default xml-based storage from OpenMRU.Core
            MRUItemFileStorage storage = new MRUItemFileStorage("demo_mru_storage.xml");

            // create default manager from OpenMRU.Core
            manager = new MRUManager();
            // init manager with storage
            manager.Initialize(storage);
            // subscribe to 'item selected' event
            manager.MRUItemSelected += Manager_MRUItemSelected;
            // init GUI control with created manager and default (eng) localization
            mruItemsControl1.Initialize(manager, new MRUGuiLocalization());

            // init menu items
            MRUItemsMenu itemsMenu = new MRUItemsMenu();

            itemsMenu.Initialize(manager, new MRUGuiLocalization());
            itemsMenu.AttachToMenu(recentFilesToolStripMenuItem);


            // init menu items - custom appearance
            MRUItemsMenu itemsMenu2 = new MRUItemsMenu();

            itemsMenu2.Initialize(manager, new MRUGuiLocalization());
            itemsMenu2.AttachToMenu(recentcustomToolStripMenuItem, "%FileName% - [%Path%] - [%AccessDate%]");
        }
Пример #2
0
 public void ShouldNotCreateStorageWithInvalidPath()
 {
     Assert.ThrowsException <ArgumentException>(() => {
         string path = null;
         MRUItemFileStorage fileStorage = new MRUItemFileStorage(path);
     }, "Storage created with invalid file path");
 }
Пример #3
0
 public void ShouldNotCreateStorageWithInvalidExtension()
 {
     Assert.ThrowsException <ArgumentException>(() => {
         string path = ".mrustorage.pdf";
         MRUItemFileStorage fileStorage = new MRUItemFileStorage(path);
     }, "Storage created with invalid file extension");
 }
Пример #4
0
        public void ShouldReturnEmptyListFromEmptyStorageFile()
        {
            MRUItemFileStorage fileStorage = new MRUItemFileStorage(path);
            List <MRUItem>     items       = fileStorage.ReadMRUItems() as List <MRUItem>;

            Assert.IsNotNull(items);
            Assert.IsTrue(items.Count == 0);
        }
Пример #5
0
        public void ShouldSaveAndReadMRUItems()
        {
            MRUItemFileStorage fileStorage = new MRUItemFileStorage(path);
            List <MRUItem>     items       = CreateItems();

            fileStorage.SaveMRUItems(items);

            List <MRUItem> readedItems = fileStorage.ReadMRUItems() as List <MRUItem>;

            Assert.IsNotNull(readedItems);
            Assert.IsTrue(readedItems.Count == 2);
            Assert.IsTrue(readedItems[0].FilePath == "path1");
            Assert.IsTrue(readedItems[0].Pinned);
        }
Пример #6
0
        public void ShouldCreateStorageWithValidPath()
        {
            MRUItemFileStorage fileStorage = new MRUItemFileStorage(path);

            Assert.IsNotNull(fileStorage);
        }