コード例 #1
0
        /// <summary>
        /// Static method to get an instance of our Veritas Repostiory.  
        /// Checks to see if we have a context in case we're using 
        /// this in a unit test.
        /// </summary>
        /// <returns></returns>
        public static VeritasRepository GetInstance()
        {
            if (HttpContext.Current == null)
                return new VeritasRepository();

            if (HttpContext.Current.Items.Contains(CACHE_KEY))
                return (VeritasRepository)HttpContext.Current.Items[CACHE_KEY];

            VeritasRepository repo = new VeritasRepository();
            HttpContext.Current.Items[CACHE_KEY] = repo;
            return repo;
        }
コード例 #2
0
 /// <summary>
 /// Forces us to get a new instace for testing purposes
 /// </summary>
 /// <returns></returns>
 public static VeritasRepository ForceNewInstance()
 {
     VeritasRepository repo = new VeritasRepository();
     if (HttpContext.Current != null)
     {
         if (HttpContext.Current.Items.Contains(CACHE_KEY))
             HttpContext.Current.Items[CACHE_KEY] = repo;
         else
             HttpContext.Current.Items.Add(CACHE_KEY, repo);
     }
     return repo;
 }
コード例 #3
0
ファイル: TestBase.cs プロジェクト: ChrisRisner/Veritas
        public void MyTestInitialize()
        {
            HttpContext.Current = new HttpContext(
                new HttpRequest("test.aspx", "http://localhosttest/test.aspx", ""),
                new HttpResponse(new StringWriter())
                );

            repo = VeritasRepository.GetInstance();
            repo.StartTransaction();

            //Insert our fake BlogConfig
            BlogConfig blogConfig = FakeModelCreator.GetFakeBlogConfig();
            repo.Add(blogConfig);
            TestBlogConfig = blogConfig;

            repo.Save();
            TestBlogConfig.LoadConfigFromXml();

            TestBlogUser = FakeModelCreator.GetFakeBlogUser(TestBlogConfig.BlogConfigId);
            repo.Add(TestBlogUser);
            repo.Save();

            TestBlogEntry = FakeModelCreator.GetFakeBlogEntry(TestBlogConfig.BlogConfigId, TestBlogUser.BlogUserId);
            repo.Add(TestBlogEntry);
            TestBlogCategory = FakeModelCreator.GetFakeBlogCategory(TestBlogConfig.BlogConfigId, TestBlogUser.BlogUserId);
            repo.Add(TestBlogCategory);
            TestBlogFeedbackAuthor = FakeModelCreator.GetFakeBlogFeedbackAuthor(TestBlogConfig.BlogConfigId);
            repo.Add(TestBlogFeedbackAuthor);
            TestBlogRole = FakeModelCreator.GetFakeBlogRole(TestBlogConfig.BlogConfigId);
            repo.Add(TestBlogRole);
            TestBlogUserRole = FakeModelCreator.GetFakeBlogUserRole(TestBlogUser.BlogUserId, TestBlogRole.BlogRoleId);
            repo.Add(TestBlogUserRole);
            TestBlogLog = FakeModelCreator.GetFakeBlogLog(TestBlogConfig.BlogConfigId);
            repo.Add(TestBlogLog);
            TestBlogMenuItem = FakeModelCreator.GetFakeBlogMenuItem(TestBlogConfig.BlogConfigId);
            repo.Add(TestBlogMenuItem);
            TestBlogPage = FakeModelCreator.GetFakeBlogPage(TestBlogConfig.BlogConfigId, TestBlogUser.BlogUserId);
            repo.Add(TestBlogPage);
            TestBlogMedia = FakeModelCreator.GetFakeBlogMedia(TestBlogConfig.BlogConfigId, TestBlogUser.BlogUserId);
            repo.Add(TestBlogMedia);
            TestBlogFeedback = FakeModelCreator.GetFakeBlogFeedback(TestBlogConfig.BlogConfigId, TestBlogEntry.BlogEntryId, TestBlogFeedbackAuthor.BlogFeedbackAuthorId);
            repo.Add(TestBlogFeedback);
            TestBlacklist = FakeModelCreator.GetFakeBlacklist(TestBlogConfig.BlogConfigId);
            repo.Add(TestBlacklist);
            TestBlogEntryCategory = FakeModelCreator.GetFakeBlogEntryCategory(TestBlogEntry.BlogEntryId, TestBlogCategory.BlogCategoryId);
            repo.Add(TestBlogEntryCategory);
            TestBlogEntryViewCount = FakeModelCreator.GetFakeBlogEntryViewCount(TestBlogConfig.BlogConfigId, TestBlogEntry.BlogEntryId);
            repo.Add(TestBlogEntryViewCount);

            repo.Save();
            if (!Directory.Exists("C:\\VeritasTestLogs"))
                Directory.CreateDirectory("C:\\VeritasTestLogs");
        }