예제 #1
0
 public void CreateBlogAlias()
 {
     Blog blog = UnitTestHelper.CreateBlogAndSetupContext();
     var alias = new BlogAlias();
     alias.BlogId = blog.Id;
     alias.Host = UnitTestHelper.GenerateUniqueString();
     alias.Subfolder = UnitTestHelper.GenerateUniqueString();
     Config.AddBlogAlias(alias);
     Assert.AreNotEqual(alias.Id, NullValue.NullInt32);
 }
예제 #2
0
 public void CreateBlogAlias()
 {
     BlogInfo blog = UnitTestHelper.CreateBlogAndSetupContext();
     BlogAlias alias = new BlogAlias();
     alias.BlogId = blog.Id;
     alias.Host = UnitTestHelper.GenerateRandomString();
     alias.Subfolder = UnitTestHelper.GenerateRandomString();
     Config.AddBlogAlias(alias);
     Assert.AreNotEqual(alias.Id, NullValue.NullInt32);
     Console.WriteLine(alias.Id.ToString(), "Alias not created.");
 }
예제 #3
0
        public void CreateBlogAlias()
        {
            // Arrange
            Blog blog = UnitTestHelper.CreateBlogAndSetupContext();
            var repository = new DatabaseObjectProvider();
            var alias = new BlogAlias();
            alias.BlogId = blog.Id;
            alias.Host = UnitTestHelper.GenerateUniqueString();
            alias.Subfolder = UnitTestHelper.GenerateUniqueString();

            // Act
            repository.AddBlogAlias(alias);

            // Assert
            Assert.AreNotEqual(alias.Id, NullValue.NullInt32);
        }
 public void AliasRedirectHandlesSubfolder()
 {
     Config.CreateBlog("title", "username", "password", "subtextproject.com", string.Empty);
     Config.CreateBlog("title", "username", "password", "example.com", string.Empty);
     BlogAlias alias = new BlogAlias();
     alias.BlogId = Config.GetBlogInfo("example.com", string.Empty).Id;
     alias.Host = "alias.example.com";
     alias.Subfolder = "blog";
     alias.IsActive = true;
     Config.AddBlogAlias(alias);
     UnitTestHelper.SetHttpContextWithBlogRequest("alias.example.com", "blog");
     BlogRequest.Current = new BlogRequest("alias.example.com", "blog", new Uri("http://alias.example.com/blog/2007/01/23/some-post.aspx"), false);
     Assert.IsNull(UrlBasedBlogInfoProvider.Instance.GetBlogInfo(), "Should return null");
     Assert.AreEqual(301, HttpContext.Current.Response.StatusCode, "Expected a 301 status code");
     Assert.AreEqual("http://example.com:80/2007/01/23/some-post.aspx", HttpContext.Current.Response.RedirectLocation, "Expected the url to change");
 }
예제 #5
0
        protected void btnAliasSave_Click(object sender, EventArgs e)
        {
            var alias = new BlogAlias();
            if(AliasId != NullValue.NullInt32)
            {
                alias.Id = AliasId;
            }

            alias.Host = txtAliasHost.Text;
            alias.Subfolder = txtAliasApplication.Text;
            alias.BlogId = BlogId;
            alias.IsActive = cbAliasActive.Checked;

            if(AliasId == NullValue.NullInt32)
            {
                Config.AddBlogAlias(alias);
            }
            else
            {
                Config.UpdateBlogAlias(alias);
            }

            AliasId = NullValue.NullInt32;
            BindEdit();
            SetAliasEdit(false);
        }
예제 #6
0
        public void CreateBlogCannotCreateBlogWithHostThatIsDuplicateOfAnotherBlogAlias()
        {
            Config.CreateBlog("title", "username", "password", _hostName, string.Empty);
            var alias = new BlogAlias {Host = "example.com", IsActive = true, BlogId = Config.GetBlog(_hostName, string.Empty).Id};
            Config.AddBlogAlias(alias);

            UnitTestHelper.AssertThrows<BlogDuplicationException>(() =>  Config.CreateBlog("title", "username2", "password2", "example.com", string.Empty));
        }
예제 #7
0
        public void GetBlogAliasByBlog()
        {
            var repository = new DatabaseObjectProvider();
            string host = UnitTestHelper.GenerateUniqueString();
            Blog blog1 = UnitTestHelper.CreateBlogAndSetupContext();
            Blog blog2 = UnitTestHelper.CreateBlogAndSetupContext();
            var alias1 = new BlogAlias();
            alias1.BlogId = blog1.Id;
            alias1.Host = host;

            var alias2 = new BlogAlias();
            alias2.BlogId = blog2.Id;
            alias2.Host = host;
            alias2.Subfolder = UnitTestHelper.GenerateUniqueString();

            repository.AddBlogAlias(alias1);
            repository.AddBlogAlias(alias2);

            IPagedCollection<BlogAlias> aliases = blog1.GetBlogAliases(new DatabaseObjectProvider(), 0, 10);
            Assert.AreEqual(1, aliases.Count);
            Assert.AreEqual(alias1.Id, aliases[0].Id);
            Assert.IsEmpty(alias1.Subfolder);
        }
예제 #8
0
        public void CreateBlogCannotCreateBlogWithHostThatIsDuplicateOfAnotherBlogAlias()
        {
            var repository = new DatabaseObjectProvider();
            repository.CreateBlog("title", "username", "password", _hostName, string.Empty);
            var alias = new BlogAlias { Host = "example.com", IsActive = true, BlogId = repository.GetBlog(_hostName, string.Empty).Id };
            repository.AddBlogAlias(alias);

            UnitTestHelper.AssertThrows<BlogDuplicationException>(() => repository.CreateBlog("title", "username2", "password2", "example.com", string.Empty));
        }
예제 #9
0
        public void CreateBlogCannotCreateBlogWithHostThatIsDuplicateOfAnotherBlogAlias()
        {
            Config.CreateBlog("title", "username", "password", _hostName, string.Empty);
            BlogAlias alias = new BlogAlias();
            alias.Host = "example.com";
            alias.IsActive = true;
            alias.BlogId = Config.GetBlogInfo(_hostName, string.Empty).Id;
            Config.AddBlogAlias(alias);

            try
            {
                Config.CreateBlog("title", "username2", "password2", "example.com", string.Empty);
            }
            catch (BlogDuplicationException)
            {
                return;
            }
            catch (Exception e)
            {
                Assert.Fail("Expected BlogDuplicationException but got " + e);
            }
            Assert.Fail("Expected BlogDuplicationException");
        }
예제 #10
0
        public void GetBlogAliasByBlog()
        {
            string host = UnitTestHelper.GenerateRandomString();
            BlogInfo blog1 = UnitTestHelper.CreateBlogAndSetupContext();
            BlogInfo blog2 = UnitTestHelper.CreateBlogAndSetupContext();
            BlogAlias alias1 = new BlogAlias();
            alias1.BlogId = blog1.Id;
            alias1.Host = host;

            BlogAlias alias2 = new BlogAlias();
            alias2.BlogId = blog2.Id;
            alias2.Host = host;
            alias2.Subfolder = UnitTestHelper.GenerateRandomString();

            Config.AddBlogAlias(alias1);
            Config.AddBlogAlias(alias2);

            IPagedCollection<BlogAlias> aliases = blog1.GetBlogAliases(0, 10);
            Assert.AreEqual(1, aliases.Count);
            Assert.AreEqual(alias1.Id, aliases[0].Id);
            Assert.IsEmpty(alias1.Subfolder);
        }