コード例 #1
0
        public void WebRepositoryFactory_CanCreateWebRepository()
        {
            this.dataAccessLayer = new DataAccessLayer();
            this.session = this.dataAccessLayer.OpenSession();

            int newRepoId;
            IDictionary<string, string> sq;

            using (WebRepositoryFactory factory = new WebRepositoryFactory("this is a bad passphrase"))
            {

                sq = new Dictionary<string, string>() {
                    { "question1", "answer1" },
                    { "question2", "answer2" },
                    { "question3", "answer3" }
                };

                newRepoId = factory.CreateWebRepository(
                                WebRepositoryType.Tangerine,
                                "my test repository",
                                "https://www.tangerine.ca/en/index.html",
                                "myuseraccountname",
                                "123456",
                                sq);
            }

            WebRepositoryData repo = this.session
                .Get<WebRepositoryData>(newRepoId);

            Assert.AreEqual(newRepoId, repo.Id);
            Assert.AreEqual("my test repository", repo.Name);
            Assert.AreEqual(WebRepositoryType.Tangerine, repo.Type);

            // check that data is encrypted.
            foreach (string key in repo.Configuration.SecurityQuestions.Keys)
            {
                Assert.IsFalse(sq.ContainsKey(key));
            }

            Assert.AreNotEqual(
                "myuseraccountname",
                repo.Configuration.Username);

            Assert.AreNotEqual(
                "123456",
                repo.Configuration.Password);

            using (ITransaction tx = session.BeginTransaction())
            {
                session.Delete(repo);
                tx.Commit();
            }

            this.session.Dispose();
            this.session = null;

            this.dataAccessLayer.Dispose();
            this.dataAccessLayer = null;
        }
コード例 #2
0
 /// <summary>
 /// Dispose the specified disposing.
 /// </summary>
 /// <param name="disposing">If set to <c>true</c> disposing.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.dal != null)
         {
             this.dal.Dispose();
             this.dal = null;
         }
     }
 }