public void MaxItemsPerPage_ReturnsOrderedPageSource() { var orderedSource = new OrderedSource<string>(new[] { "hello", "world" }.AsQueryable().OrderBy(s => s)); var orderedPageSource = new OrderedPageSourceModel<string, PageRequestModel>(5, 1, orderedSource, new PageRequestModel()); var newPageSource = orderedPageSource.MaxItemsPerPage(43); Assert.AreSame(orderedPageSource.Source, newPageSource.Source); Assert.AreSame(orderedPageSource.Request, newPageSource.Request); Assert.AreEqual(orderedPageSource.GetDefaultItemsPerPage(), newPageSource.GetDefaultItemsPerPage()); Assert.AreEqual(43, newPageSource.GetMaxItemsPerPage()); Assert.IsInstanceOf(typeof(OrderedPageSourceModel<string, PageRequestModel>), newPageSource); var newNewPageSource = ((IOrderedPageSourceModel<string, PageRequestModel>)orderedPageSource).MaxItemsPerPage(52); Assert.AreSame(orderedPageSource.Source, newNewPageSource.Source); Assert.AreSame(orderedPageSource.Request, newNewPageSource.Request); Assert.AreEqual(orderedPageSource.GetDefaultItemsPerPage(), newNewPageSource.GetDefaultItemsPerPage()); Assert.AreEqual(52, newNewPageSource.GetMaxItemsPerPage()); Assert.IsInstanceOf(typeof(OrderedPageSourceModel<string, PageRequestModel>), newNewPageSource); }
public void MaxItemsPerPage_ReturnsOrderedPageSource() { var orderedSource = new OrderedSource <string>(new[] { "hello", "world" }.AsQueryable().OrderBy(s => s)); var orderedPageSource = new OrderedPageSourceModel <string, PageRequestModel>(5, 1, orderedSource, new PageRequestModel()); var newPageSource = orderedPageSource.MaxItemsPerPage(43); Assert.AreSame(orderedPageSource.Source, newPageSource.Source); Assert.AreSame(orderedPageSource.Request, newPageSource.Request); Assert.AreEqual(orderedPageSource.GetDefaultItemsPerPage(), newPageSource.GetDefaultItemsPerPage()); Assert.AreEqual(43, newPageSource.GetMaxItemsPerPage()); Assert.IsInstanceOf(typeof(OrderedPageSourceModel <string, PageRequestModel>), newPageSource); var newNewPageSource = ((IOrderedPageSourceModel <string, PageRequestModel>)orderedPageSource).MaxItemsPerPage(52); Assert.AreSame(orderedPageSource.Source, newNewPageSource.Source); Assert.AreSame(orderedPageSource.Request, newNewPageSource.Request); Assert.AreEqual(orderedPageSource.GetDefaultItemsPerPage(), newNewPageSource.GetDefaultItemsPerPage()); Assert.AreEqual(52, newNewPageSource.GetMaxItemsPerPage()); Assert.IsInstanceOf(typeof(OrderedPageSourceModel <string, PageRequestModel>), newNewPageSource); }
public void ThenByDescending_ReturnsOrderedSourceThenByDescending() { var thenBy = new Mock <IOrderedSource <string> >(); var orderedSource = new Mock <IOrderedSource <string> >(MockBehavior.Strict); Expression <Func <String, int> > keySelector = s => s.Length; orderedSource.Setup(s => s.ThenByDescending(keySelector)).Returns(thenBy.Object).Verifiable("The source was not ordered then by descending by the key selector."); var m1 = new OrderedPageSourceModel <string, PageRequestModel>(8, 7, orderedSource.Object, new PageRequestModel()); var m2 = m1.ThenByDescending(keySelector); orderedSource.Verify(); Assert.AreEqual(m1.GetMaxItemsPerPage(), m2.GetMaxItemsPerPage()); Assert.AreEqual(m1.GetDefaultItemsPerPage(), m2.GetDefaultItemsPerPage()); Assert.AreSame(thenBy.Object, m2.Source); Assert.AreSame(m1.Request, m2.Request); }
public void ThenBy_ReturnsOrderedSourceThenBy() { var thenBy = new Mock<IOrderedSource<string>>(); var orderedSource = new Mock<IOrderedSource<string>>(MockBehavior.Strict); Expression<Func<String, int>> keySelector = s => s.Length; orderedSource.Setup(s => s.ThenBy(keySelector)).Returns(thenBy.Object).Verifiable("The source was not ordered then by by the key selector."); var m1 = new OrderedPageSourceModel<string, PageRequestModel>(8, 7, orderedSource.Object, new PageRequestModel()); var m2 = m1.ThenBy(keySelector); orderedSource.Verify(); Assert.AreEqual(m1.GetMaxItemsPerPage(), m2.GetMaxItemsPerPage()); Assert.AreEqual(m1.GetDefaultItemsPerPage(), m2.GetDefaultItemsPerPage()); Assert.AreSame(thenBy.Object, m2.Source); Assert.AreSame(m1.Request, m2.Request); }