Example #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);
        }
Example #2
0
        public void GetIdenitfiers_NoIdentifiersAtAll_WikiRepositoryExceptionIsThrown()
        {
            IWikiRepository repository = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);

            //Possible that there are already wiki objects loaded, because of the other tests.
            //If not the exception is already thrown here.
            foreach (string identifier in repository.GetIdentifiers())
            {
                repository.Delete(identifier);
            }

            //Now it should definitly throw the exception
            repository.GetIdentifiers();
        }
Example #3
0
        public void GetIdentifiers_StandardProcedure_AListOfStringsIsReturned()
        {
            bool found = false;

            WikiAccount account = new WikiAccount();

            account.AccountName = "foobar";
            account.LoginName   = "barfoo";
            account.Password    = "******";
            account.WikiUrl     = new Uri("http://some.where.over/the/Rainbow");

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

            foreach (string identifier in repository.GetIdentifiers())
            {
                Assert.IsFalse(String.IsNullOrEmpty(identifier));
                if (targetIdentifier == identifier)
                {
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found);
        }
Example #4
0
        public void Constructor_RepositoryIsCreated_CreationWithoutErrors()
        {
            IWikiRepository repository = WikiRepositoryFactory.CreateRepository(WikiRepositoryType.FileRepository);

            try
            {
                foreach (string identifier in repository.GetIdentifiers())
                {
                    Console.WriteLine("Loaded business object with identifier: {0}" + identifier);
                }
            }
            catch (WikiRepositoryException wre)
            {
                Console.WriteLine(wre.Message);
            }
        }
Example #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);
        }