Beispiel #1
0
        /// <summary>
        /// Loads the wiki accounts.
        /// </summary>
        /// <returns></returns>
        public List <WikiAccount> LoadWikiAccounts()
        {
            List <WikiAccount> accounts = new List <WikiAccount>();

            List <string> identifiers;

            try
            {
                identifiers = (List <string>)repository.GetIdentifiers();
            }
            catch (WikiRepositoryException)
            {
                identifiers = new List <string>();
            }

            foreach (string identifier in identifiers)
            {
                WikiAccount loadedAccount = repository.Load <WikiAccount>(identifier);
                if (loadedAccount != null)
                {
                    accounts.Add(loadedAccount);
                }
            }

            return(accounts);
        }
Beispiel #2
0
        public void Load_LoadAWikiAccount_IsLoadedWithoutErrors()
        {
            WikiAccount expectedAccount = new WikiAccount();

            expectedAccount.AccountName = "doodle";
            expectedAccount.LoginName   = "Dödel";
            expectedAccount.Password    = "******";
            expectedAccount.WikiUrl     = new Uri("http://www.doodle.ch/tinyurl/349");

            IWikiRepository repository       = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);
            string          targetIdenitfier = repository.Store <WikiAccount>(expectedAccount);

            WikiAccount targetAccount = repository.Load <WikiAccount>(targetIdenitfier);

            Assert.AreEqual(targetAccount, expectedAccount);
            Assert.IsTrue(targetAccount.Equals(expectedAccount));
        }
Beispiel #3
0
        public void Store_StoreAWikiObjectUsingItsOwnIdenitfier_ShouldBeDoneWithoutErrors()
        {
            WikiAccount myOwnAccount = new WikiAccount();

            myOwnAccount.LoginName = "jfdsah";
            myOwnAccount.Password  = "******";
            myOwnAccount.WikiUrl   = new Uri("ftp://ftp.google.com/");

            IWikiRepository repository = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);
            string          accountId  = "MyOwnAccount";

            repository.Store <WikiAccount>(myOwnAccount, accountId);

            WikiAccount reloadedAccount = repository.Load <WikiAccount>(accountId);

            Assert.IsNotNull(reloadedAccount);
            Assert.AreEqual(myOwnAccount, reloadedAccount);
        }
Beispiel #4
0
        public void Load_LoadAPersistedWikiPage_ShouldBeLoadedWithoutErrors()
        {
            WikiAccount account     = new WikiAccount();
            Wikipage    pageToStore = new Wikipage(account);

            pageToStore.WikiPageName    = "first.php";
            pageToStore.WikiPageContent = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr ...";

            IWikiRepository repository     = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);
            string          pageIdentifier = repository.Store <Wikipage>(pageToStore);

            repository = null;
            repository = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);

            Wikipage loadedPage = repository.Load <Wikipage>(pageIdentifier);

            Assert.AreEqual(pageToStore, loadedPage);
        }
Beispiel #5
0
        public void Load_LoadAManualPersistedWikiObject_IsLoadedAndAddedInRepository()
        {
            WikiAccount manualStoredAccount = new WikiAccount();

            manualStoredAccount.AccountName = "doodleidu";
            manualStoredAccount.LoginName   = "Dödeldidu";
            manualStoredAccount.Password    = "******";
            manualStoredAccount.WikiUrl     = new Uri("http://www.doodle.ch/tinyurl/987436219874");

            IWikiRepository repository       = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);
            string          targetIdenitfier = manualStoredAccount.Serialize(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "//DokuWikiStore//", ".wiki");

            WikiAccount loadedAccount = repository.Load <WikiAccount>(targetIdenitfier);

            Assert.IsNotNull(loadedAccount);
            Assert.AreEqual(manualStoredAccount, loadedAccount);

            string addedIdentifier = repository.GetIdentifiers().First(x => x.Equals(targetIdenitfier));

            Assert.AreEqual(addedIdentifier, targetIdenitfier);
        }