Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public void Store_StoreAModifiedWikiAccount_IdentifierShouldStayTheSame()
        {
            WikiAccount account     = new WikiAccount();
            Wikipage    pageToStore = new Wikipage(account);

            pageToStore.WikiPageName    = "first.php";
            pageToStore.WikiPageContent = "Lorem ipsum dolor sit amet";

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

            pageToStore.WikiPageContent = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr," +
                                          " sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.";
            string secondIdentifier = repository.Store <Wikipage>(pageToStore);

            Assert.AreEqual(firstIdentifier, secondIdentifier);
        }
Ejemplo n.º 3
0
        public void Delete_SaveAndThenDeleteAWikiPage_ShouldBeDoneWithoutErrors()
        {
            WikiAccount account     = new WikiAccount();
            Wikipage    pageToStore = new Wikipage(account);

            pageToStore.WikiPageName    = "delete.php";
            pageToStore.WikiPageContent = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut labore et dolore ...";

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

            repository.Delete(pageIdentifier);
        }
Ejemplo n.º 4
0
        public void Store_StoreAWikiPage_BusinessObjectShouldBeStoredWithoutErrors()
        {
            WikiAccount account = new WikiAccount();
            Wikipage    page    = new Wikipage(account);

            page.WikiPageContent = "ölkjölkfsajdölkjafsd";
            page.WikiPageName    = "start.php";

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

            Assert.IsFalse(String.IsNullOrEmpty(identifier));
            Assert.AreEqual(identifier, page.ObjectIdentifier);
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Saves the wiki account.
 /// </summary>
 /// <param name="accountToSave">The account to save.</param>
 public void SaveWikiAccount(WikiAccount accountToSave)
 {
     repository.Store <WikiAccount>(accountToSave);
 }