示例#1
0
 public void MaximumPageNumberIs8_ShouldGenerateCorrectHtml()
 {
     _testList.PageSize = 5;
     IHtmlString html = _ajaxHelper.Pager(_testList).Options(o=>o.SetPageIndexParameterName("id").SetMaximumPageNumber(8)).AjaxOptions(a=>a.SetUpdateTargetId("test"));
     string htmlStr = html.ToHtmlString();
     const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#test\"","data-pagecount=\"8\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"","data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     sb.Append("FirstPrev1");
     for (int i = 2; i <= 8; i++)
     {
         sb.AppendFormat(linkFormat, i, i);
     }
     sb.AppendFormat(linkFormat, 2, "Next");
     sb.AppendFormat(linkFormat, 8, "Last");
     sb.Append("</div>");
     sb.Append(TestHelper.CopyrightText);
     Assert.AreEqual(htmlStr, sb.ToString());
 }
        public void In_memory_DbSet_can_be_used_for_AddRange()
        {
            var set = new InMemoryNonGenericDbSet<Product>();
            var products = new[] { new Product { Id = 1 }, new Product { Id = 2 } };

            Assert.Same(products, set.AddRange(products));
            Assert.Equal(products.OrderBy(p => p.Id), set.ToList<Product>().OrderBy(p => p.Id));
        }
        /// <summary>
        /// The index.
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Index()
        {
            var data = new Dictionary<string, object>();

            var transformationLinks = new[] { Link.Start, Link.End, Link.CycleStart, Link.CycleEnd };
            transformationLinks = transformationLinks.OrderBy(n => (int)n).ToArray();
            data.Add("transformationLinks", transformationLinks.ToSelectList());

            var operations = new List<SelectListItem> { new SelectListItem { Text = "Dissimilar", Value = 1.ToString() }, new SelectListItem { Text = "Higher order", Value = 2.ToString() } };
            data.Add("operations", operations);

            ViewBag.data = JsonConvert.SerializeObject(data);
            return View();
        }
示例#4
0
        public void ShouldDetectAStraight()
        {
            var cards = new[] {
                                  2.Of(Suit.Spades),
                                  3.Of(Suit.Hearts),
                                  4.Of(Suit.Spades),
                                  5.Of(Suit.Spades),
                                  6.Of(Suit.Clubs),
                                  Picture.Ace.Of(Suit.Hearts),
                                  Picture.King.Of(Suit.Clubs)
                              };

            IEnumerable<Card> result =  new Straight().Match(cards);

            Assert.That( result, Is.EquivalentTo(cards.OrderBy( x=> x.Rank).Take(5)), "Should have matched the consecutive cards.");
        }
示例#5
0
 public void AlwaysShowFirstLastPageNumberWithCurrentPageIndexIs12_ShouldGenerateCorrectHtml()
 {
     _testList.PageSize = 2;
     _testList.CurrentPageIndex = 12;
     IHtmlString html = _ajaxHelper.Pager(_testList).Options(o=>o.SetPageIndexParameterName("id").AlwaysShowFirstLastPageNumber()).AjaxOptions(a=>a.SetUpdateTargetId("test"));
     string htmlStr = html.ToHtmlString();
     const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-currentpage=\"12\"","data-firstpage=\"" + BaseLink + "\"",
         "data-ajax=\"true\"", "data-ajax-update=\"#test\"","data-pagecount=\"44\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"","data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     sb.Append("<a data-pageindex=\"1\" href=\"").Append(BaseLink).Append("\">First</a>");
     sb.AppendFormat(linkFormat, 11, "Prev");
     sb.Append("<a data-pageindex=\"1\" href=\"").Append(BaseLink).Append("\">1</a>");
     sb.AppendFormat(linkFormat, 6, "...");
     for (int i = 7; i <= 16; i++)
     {
         if (i == 12)
             sb.Append(i);
         else
         {
             sb.AppendFormat(linkFormat, i, i);
         }
     }
     sb.AppendFormat(linkFormat, 17, "...");
     sb.AppendFormat(linkFormat, 44, "44");
     sb.AppendFormat(linkFormat, 13, "Next");
     sb.AppendFormat(linkFormat, 44, "Last");
     sb.Append("</div>");
     sb.Append(TestHelper.CopyrightText);
     Assert.AreEqual(htmlStr, sb.ToString());
 }
示例#6
0
 public void CurrentPageNumberFormatString_PagerItemTemplate_ShouldGenerateCorrectHtml()
 {
     _testList.CurrentPageIndex = 6;
     const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
     IHtmlString html = _ajaxHelper.Pager(_testList, 
                                            new PagerOptions
                                            {
                                                PageIndexParameterName = "id",
                                                CurrentPagerItemTemplate =
                                                    "<span class=\"current\">{0}</span>",
                                                CurrentPageNumberFormatString = "-{0}-"
                                            }, new MvcAjaxOptions { UpdateTargetId = "uptarget" }); 
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","data-currentpage=\"6\"","data-firstpage=\"" + BaseLink + "\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     sb.AppendFormat("<a data-pageindex=\"1\" href=\"{0}\">First</a>", BaseLink);
     sb.AppendFormat(linkFormat, 5, "Prev");
     sb.AppendFormat("<a data-pageindex=\"1\" href=\"{0}\">1</a>", BaseLink);
     for (int i = 2; i <= 10; i++)
     {
         if (i == 6)
             sb.Append("<span class=\"current\">-6-</span>");
         else
             sb.AppendFormat(linkFormat, i, i);
     }
     sb.AppendFormat(linkFormat, 11, "...");
     sb.AppendFormat(linkFormat, 7, "Next");
     sb.AppendFormat(linkFormat, 11, "Last");
     sb.Append("</div>").Append(TestHelper.CopyrightText);
     Assert.AreEqual(html.ToHtmlString(), sb.ToString());
 }
示例#7
0
 public void MvcAjaxOptions_DisallowCache_ShouldGenerateCorrectAttributes()
 {
     _testList.CurrentPageIndex = 3;
     IHtmlString html = _ajaxHelper.Pager(_testList, new PagerOptions { PageIndexParameterName = "id" }, new MvcAjaxOptions { UpdateTargetId = "uptarget", AllowCache = false });
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","data-currentpage=\"3\"","data-firstpage=\""+BaseLink+"\"",
         "data-ajax-allowcache=\"false\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\""
     };
     var sb=new StringBuilder("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     StringAssert.Contains(html.ToHtmlString(), sb.ToString());}
      public void Should_ReturnCourseAuthors()
      {
         // Arrange
         var coAuthors = new[] { "Eric Burke", "Steve Evans", "Rob Windsor" }
            .Select(x => new PluralsightAuthor { FullName = x }).ToList();

         var author = new PluralsightAuthor { FullName = "John Smith", UrlName = "john-smith"};

         var coAuthorNode = Mock.Of<INode>();
         var authorNode = Mock.Of<INode>();

         var course = new PluralsightCourse();

         var fullnamesakesAuthorsContainer = new Dictionary<IAuthorFullNameNaturalKey, PluralsightAuthor>(
            FullNameNaturalKeyEqualityComparer<IAuthorFullNameNaturalKey>.Instance);

         fullnamesakesAuthorsContainer.Add(coAuthors[1], coAuthors[1]);


         var allAuthorsExceptFullnamesakesContainer = new Dictionary<IAuthorFullNameNaturalKey, PluralsightAuthor>(
            FullNameNaturalKeyEqualityComparer<IAuthorFullNameNaturalKey>.Instance);

         allAuthorsExceptFullnamesakesContainer.Add(coAuthors[0], coAuthors[0]);
         allAuthorsExceptFullnamesakesContainer.Add(coAuthors[2], coAuthors[2]);
         allAuthorsExceptFullnamesakesContainer.Add(author, author);

         var allAuthorsExceptWhoseUrlNullContainer = new Dictionary<IAuthorUrlNameNaturalKey, PluralsightAuthor>(
            UrlNameNaturalKeyEqualityComparer<IAuthorUrlNameNaturalKey>.Instance);
         allAuthorsExceptWhoseUrlNullContainer.Add(author, author);

         var authorsParseResult = new PluralsightCatalogParser.AuthorsParseResult
         {
            FullnamesakesAuthorsContainer = fullnamesakesAuthorsContainer,
            AllAuthorsByFullNameExceptFullnamesakesContainer = allAuthorsExceptFullnamesakesContainer,
            AllAuthorsExceptWhoseUrlNullContainer = allAuthorsExceptWhoseUrlNullContainer
         };


         var nodeSelector = Mock.Of<INodeSelector>();

         var nodeParser = Mock.Of<INodeParser>(x =>
            x.IsCoAuthorNode(coAuthorNode) == true &&
            x.ParseCoAuthors(coAuthorNode) == coAuthors &&

            x.IsCoAuthorNode(authorNode) == false &&
            x.ParseAuthor(authorNode) == author);

         var sut = new PluralsightCatalogParser(nodeSelector, nodeParser);

         // Act
         var result = sut.GetCourseAuthors(new[] { authorNode, coAuthorNode }, course, authorsParseResult);

         // Assert
         Assert.NotNull(result);
         Assert.Equal(4, result.Count);

         foreach (var courseAuthor in result)
         {
            Assert.Same(course, courseAuthor.Course);
         }
         
         Assert.Equal(coAuthors.OrderBy(x => x.FullName),
            result.Where(x => x.IsAuthorCoAuthor).Select(x => x.Author).OrderBy(x => x.FullName),
            ReferenceEqualityComparer.Instance);

         Assert.Same(author, result.Single(x => x.IsAuthorCoAuthor == false).Author);

         Assert.Same(coAuthors[1], result.Single(x => x.HasFullnamesake).Author);
      }
        public void should_get_ordered_sequence()
        {
            var sequence = new[] {4, 2, 1, 3, 5};

            IOrderedEnumerable<int> orderedResult = sequence.OrderBy(item => item);

            // please update variable value to fix the test.
            IEnumerable<int> expectedOrderedResult = new[] {4, 2, 1, 3, 5};

            Assert.Equal(expectedOrderedResult, orderedResult);
        }
示例#10
0
 public void SetAjaxEvents_ShouldGenerateCorrectHtml()
 {
     _testList.CurrentPageIndex = 1;
     const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
     IHtmlString html = _ajaxHelper.Pager(_testList).Options(o=>o.SetPageIndexParameterName("id")).AjaxOptions(a=>a.SetUpdateTargetId("uptarget").SetOnBegin("function(data){alert(data);}").SetOnComplete("alert(\"complete\")").SetOnFailure("failureHandler").SetOnSuccess("showSuccessMsg"));
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"",
         "data-ajax-begin=\"" + HttpUtility.HtmlEncode("function(data){alert(data);}") + "\"",
         "data-ajax-complete=\"" + HttpUtility.HtmlEncode("alert(\"complete\")") + "\"",
         "data-ajax-failure=\"failureHandler\"","data-ajax-success=\"showSuccessMsg\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     sb.Append("First").Append("Prev").Append("1");
     for (int i = 2; i <= 10; i++)
     {
         sb.AppendFormat(linkFormat, i, i);
     }
     sb.AppendFormat(linkFormat, 11, "...");
     sb.AppendFormat(linkFormat, 2, "Next");
     sb.AppendFormat(linkFormat, 11, "Last");
     sb.Append("</div>").Append(TestHelper.CopyrightText);
     Assert.AreEqual(html.ToHtmlString(), sb.ToString());
 }
示例#11
0
 public void NavigationPagerItemsPositionIsRight_ShouldGenerateCorrectHtml()
 {
     _testList.CurrentPageIndex = 1;
     const string linkFormat =  "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
     IHtmlString html = _ajaxHelper.Pager(_testList, new PagerOptions { PageIndexParameterName = "id", NavigationPagerItemsPosition = PagerItemsPosition.Right }, new MvcAjaxOptions { UpdateTargetId = "uptarget" });
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     sb.Append("1");
     for (int i = 2; i <= 10; i++)
     {
         sb.AppendFormat(linkFormat, i, i);
     }
     sb.AppendFormat(linkFormat, 11, "...").Append("First").Append("Prev");
     sb.AppendFormat(linkFormat, 2, "Next");
     sb.AppendFormat(linkFormat, 11, "Last");
     sb.Append("</div>").Append(TestHelper.CopyrightText);
     Assert.AreEqual(html.ToHtmlString(), sb.ToString());
 }
示例#12
0
 public void CurrentPageIndexIsLargerThanTotalPageCount_ShouldGenerateCorrectHtml()
 {
     _testList.CurrentPageIndex = 88;
     IHtmlString html = _ajaxHelper.Pager(_testList).AjaxOptions(a=>a.SetUpdateTargetId("uptarget"));
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","style=\"color:red;font-weight:bold\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pagerid=\"Webdiyer.MvcPager\""
     };
     var sb=new StringBuilder("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">").Append(TestHelper.PageIndexOutOfRangeErrorMessage).Append("</div>");
     Assert.AreEqual(html.ToHtmlString(), TestHelper.CopyrightText + sb + TestHelper.CopyrightText);
 }
示例#13
0
 public void MaximumPageIndexItemsIs6_ShouldGenerateCorrectHtml()
 {
     _testList.PageSize = 5;
     IHtmlString html = _ajaxHelper.Pager(_testList).Options(o => o.SetPageIndexParameterName("id").SetPageIndexBoxId("pib").SetMaximumPageIndexItems(6)).AjaxOptions(a=>a.SetUpdateTargetId("test"));
     string htmlStr = html.ToHtmlString();
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#test\"","data-maxitems=\"6\"","data-pageindexbox=\"#pib\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"","data-pagecount=\"18\"","data-urlformat=\"" + BaseLink + "/__id__\""
     };
     var sb=new StringBuilder("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     StringAssert.Contains(htmlStr, sb.ToString());
 }
示例#14
0
 public void NumericPagerItemTemplate_ShouldOverridePagerItemTemplate()
 {
     const string linkFormat = "<span><a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a></span>";
     const string numericLinkFormat = "<span class=\"number\"><a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a></span>";
     IHtmlString html = _ajaxHelper.Pager(_testList,
                                            new PagerOptions
                                            {
                                                ContainerTagName = "ul",
                                                PageIndexParameterName = "id",
                                                PagerItemTemplate = "<span>{0}</span>",
                                                NumericPagerItemTemplate = "<span class=\"number\">{0}</span>"
                                            }, new MvcAjaxOptions { UpdateTargetId = "uptarget" });
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<ul");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     //sb.Append("<ul data-ajax=\"true\" data-ajax-update=\"#uptarget\" data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\" data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\" data-pageparameter=\"id\" data-pagerid=\"Webdiyer.MvcPager\" data-pagecount=\"11\" data-urlformat=\"").Append(BaseLink).Append("/__id__\">");
     sb.Append("<span>First</span>")
         .Append("<span>Prev</span>")
         .Append("<span>1</span>");
     for (int i = 2; i <= 10; i++)
     {
         sb.AppendFormat(numericLinkFormat, i, i);
     }
     sb.AppendFormat(linkFormat, 11, "...");
     sb.AppendFormat(linkFormat, 2, "Next");
     sb.AppendFormat(linkFormat, 11, "Last");
     sb.Append("</ul>").Append(TestHelper.CopyrightText);
     Assert.AreEqual(html.ToHtmlString(), sb.ToString());
 }
示例#15
0
 public void HidePagerItemsAndCurrentPageIndexIs6_ShouldGenerateCorrectHtml()
 {
     _testList.CurrentPageIndex = 6;
     IHtmlString html = _ajaxHelper.Pager(_testList, new PagerOptions { PageIndexParameterName = "id", HidePagerItems = true }, new MvcAjaxOptions { UpdateTargetId = "uptarget" });
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","data-currentpage=\"6\"","data-firstpage=\"" + BaseLink + "\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\"","style=\"display:none\""
     };
     var sb = new StringBuilder("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append("></div>");
     Assert.AreEqual(html.ToHtmlString(), TestHelper.CopyrightText + sb + TestHelper.CopyrightText);
 }
示例#16
0
 public void HidePagerItemsAndCurrentPageIndexIs1_ShouldGenerateCorrectHtml()
 {
     IHtmlString html = _ajaxHelper.Pager(_testList,
         new PagerOptions { PageIndexParameterName = "id", HorizontalAlign = "right", HidePagerItems = true,  HtmlAttributes = new Dictionary<string, object> { { "style", "width:99%;height:28px" } } }, new MvcAjaxOptions { UpdateTargetId = "uptarget" });
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"11\"",
         "data-urlformat=\"" + BaseLink + "/__id__\"","style=\"width:99%;height:28px;text-align:right;display:none\""
     };
     var sb=new StringBuilder("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append("></div>");
     Assert.AreEqual(html.ToHtmlString(), TestHelper.CopyrightText + sb + TestHelper.CopyrightText);
 }
示例#17
0
 public void CurrentUICultureIsEnUs_ShouldGetCorrectPropertyValuesFromResourceFile()
 {
     _testList.PageSize = 5;
     _testList.CurrentPageIndex = 13;
     IHtmlString html = _ajaxHelper.Pager(_testList, new PagerOptions { PageIndexParameterName = "id" }, new MvcAjaxOptions { UpdateTargetId = "uptarget" });
     const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + TestHelper.AppPathModifier + AppPath + "/mvcpager/test/{0}\">{1}</a>";
     var sb = new StringBuilder(TestHelper.CopyrightText);
     var attrs = new[]
     {
         "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","data-currentpage=\"13\"","data-firstpage=\""+BaseLink+"\"",
         "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
         "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
         "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"18\"",
         "data-urlformat=\"" + BaseLink + "/__id__\""
     };
     sb.Append("<div");
     foreach (var att in attrs.OrderBy(a => a))
     {
         sb.Append(" ").Append(att);
     }
     sb.Append(">");
     sb.Append("<a data-pageindex=\"1\" href=\"").Append(BaseLink).Append("\">First</a>");
     sb.AppendFormat(linkFormat, 12, "Prev");
     sb.AppendFormat(linkFormat, 7, "...");
     for (int i = 8; i < 18; i++)
     {
         if (i == 13)
             sb.Append(i);
         else
             sb.AppendFormat(linkFormat, i, i);
     }
     sb.AppendFormat(linkFormat, 18, "...");
     sb.AppendFormat(linkFormat, 14, "Next");
     sb.AppendFormat(linkFormat, 18, "Last");
     sb.Append("</div>").Append(TestHelper.CopyrightText);
     Assert.AreEqual(html.ToHtmlString(), sb.ToString());
 }
示例#18
0
        public void AlwaysShowFirstLastPageNumber_PageIndexIs13_ShouldGenerateCorrectHtml()
        {
            _testList.PageSize = 5;
            _testList.CurrentPageIndex = 13;
            var po = new PagerOptions
            {
                PageIndexParameterName = "id",
                AlwaysShowFirstLastPageNumber = true,
                ShowFirstLast = false,
                ShowPrevNext = false
            };

            IHtmlString html = _ajaxHelper.Pager(_testList, po, new MvcAjaxOptions { UpdateTargetId = "uptarget" });
            const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
            var sb = new StringBuilder(TestHelper.CopyrightText);
            var attrs = new[]
            {
                "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","data-currentpage=\"13\"","data-firstpage=\""+BaseLink+"\"",
                "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessage + "\"",
                "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessage + "\"",
                "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"18\"",
                "data-urlformat=\"" + BaseLink + "/__id__\""
            };
            sb.Append("<div");
            foreach (var att in attrs.OrderBy(a => a))
            {
                sb.Append(" ").Append(att);
            }
            sb.Append(">");
            sb.AppendFormat("<a data-pageindex=\"{0}\" href=\"" + BaseLink + "\">{1}</a>", 1, "1");
            sb.AppendFormat(linkFormat,7,"...");
            for (int i = 8; i <= 18; i++)
            {
                if (i == 13)
                    sb.Append(i);
                else
                    sb.AppendFormat(linkFormat, i, i);
            }
            sb.Append("</div>").Append(TestHelper.CopyrightText);
            Assert.AreEqual(html.ToHtmlString(), sb.ToString());
        }
示例#19
0
        public void CurrentUICultureIsZhCN_ShouldGetCorrectPropertyValuesFromResourceFile()
        {
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("zh-CN");
            _testList.PageSize = 5;
            _testList.CurrentPageIndex = 13;

            IHtmlString html = _ajaxHelper.Pager(_testList).Options(o=>o.SetPageIndexParameterName("id")).AjaxOptions(a=>a.SetUpdateTargetId("uptarget"));
            const string linkFormat = "<a data-pageindex=\"{0}\" href=\"" + BaseLink + "/{0}\">{1}</a>";
            var sb = new StringBuilder(TestHelper.CopyrightTextCn);
            var attrs = new[]
            {
                "data-ajax=\"true\"", "data-ajax-update=\"#uptarget\"","data-currentpage=\"13\"","data-firstpage=\""+BaseLink+"\"",
                "data-invalidpageerrmsg=\"" + TestHelper.InvalidPageIndexErrorMessageCn + "\"",
                "data-outrangeerrmsg=\"" + TestHelper.PageIndexOutOfRangeErrorMessageCn + "\"",
                "data-pageparameter=\"id\"", "data-pagerid=\"Webdiyer.MvcPager\"", "data-pagecount=\"18\"",
                "data-urlformat=\"" + BaseLink + "/__id__\""
            };
            sb.Append("<div");
            foreach (var att in attrs.OrderBy(a => a))
            {
                sb.Append(" ").Append(att);
            }
            sb.Append(">");
            sb.Append("<a data-pageindex=\"1\" href=\"").Append(BaseLink).Append("\">首页</a>");
            sb.AppendFormat(linkFormat, 12, "上页");
            sb.AppendFormat(linkFormat, 7, "...");
            for (int i = 8; i < 18; i++)
            {
                if (i == 13)
                    sb.Append(i);
                else
                    sb.AppendFormat(linkFormat, i, i);
            }
            sb.AppendFormat(linkFormat, 18, "...");
            sb.AppendFormat(linkFormat, 14, "下页");
            sb.AppendFormat(linkFormat, 18, "尾页");
            sb.Append("</div>").Append(TestHelper.CopyrightTextCn);
            Assert.AreEqual(html.ToHtmlString(), sb.ToString());
        }