Beispiel #1
0
 public static Pageable <HistoryModel> ToHistoryModelList(this IEnumerable <HistoryModel> srcList, Pageable <HistoryModel> destList)
 {
     if (srcList != null && srcList.Any())
     {
         destList.AddRange(srcList);
         //foreach (var src in srcList)
         //{
         //    destList.Add(src);
         //}
     }
     return(destList);
 }
Beispiel #2
0
        public void HistoryNextPage()
        {
            var results = new[] {
                new HistoryModel {
                    DateAccessed = DateTime.Now, IsPinned = false, Values = new RouteValueDictionary {
                        { "id", "123" }
                    }, DisplayName = "Foo", HistoryType = HistoryType.JobSeeker
                },
                new HistoryModel {
                    DateAccessed = DateTime.Now, IsPinned = false, Values = new RouteValueDictionary {
                        { "id", "456" }
                    }, DisplayName = "Bar", HistoryType = HistoryType.JobSeeker
                }
            };
            var metadata = new HistoryPageMetadata
            {
                HistoryType = HistoryType.JobSeeker,
                PageNumber  = 1,
                PageSize    = 1,
                Total       = 2
            };

            var getResults = new Pageable <HistoryModel>(metadata);

            getResults.AddRange(results);

            //mockMappingEngine.Setup(m => m.Map<IEnumerable<HistoryModel>, IPageable<HistoryModel>>(It.IsAny<IEnumerable<HistoryModel>>(), It.IsAny<IPageable<HistoryModel>>())).Returns(getResults);

            var        controller          = SystemUnderTest();
            var        result              = controller.HistoryNextPage(metadata);
            ViewResult viewResult          = result as ViewResult;
            IPageable <HistoryModel> model = viewResult.Model as IPageable <HistoryModel>;

            Assert.IsNotNull(viewResult, "ViewResult should not be null.");
            Assert.IsNotNull(model, "model should not be null.");
            Assert.IsTrue(model.Count() == 2);
            Assert.IsTrue(model.Metadata is HistoryPageMetadata);
            Assert.AreEqual(((HistoryPageMetadata)model.Metadata).HistoryType, HistoryType.JobSeeker);
            Assert.AreEqual(model.Metadata.PageNumber, 1);
            Assert.AreEqual(model.Metadata.PageSize, 1);
            Assert.AreEqual(model.Metadata.Total, 2);
        }
        public void TestInitialize()
        {
            mockConfigurationManager = new Mock <IConfigurationManager>();
            mockClient       = new Mock <IClient>();
            mockCacheService = new Mock <ICacheService>();
            mockSqlService   = new Mock <ISqlService>();
            mockUserService  = new Mock <IUserService>();
            // mockMappingEngine = new Mock<IMappingEngine>();

            appSettings.Add("RHEA.History.PageSize", "10");
            mockConfigurationManager.SetupGet(m => m.AppSettings).Returns(appSettings);

            mockUserService.Setup(m => m.Username).Returns(username);
            mockContainerProvider = new Mock <IContainerProvider>();
            mockContainerProvider.Setup(m => m.GetService <IUserService>()).Returns(mockUserService.Object);
            DependencyResolver.SetResolver(mockContainerProvider.Object);

            // Setup Sql Service
            var results = new[] {
                new HistoryModel {
                    DateAccessed = DateTime.Now, IsPinned = false, Values = objectValues, DisplayName = displayName, HistoryType = historyType
                }
            };

            mockSqlService.Setup(m => m.ExecuteNonQuery(It.IsAny <string>(), "rheRecentHistoryInsert", It.IsAny <IEnumerable <SqlParameter> >()));
            mockSqlService.Setup(m => m.ExecuteNonQuery(It.IsAny <string>(), "rheRecentHistoryDelete", It.IsAny <IEnumerable <SqlParameter> >()));
            mockSqlService.Setup(m => m.ExecuteNonQuery(It.IsAny <string>(), "rheRecentHistoryUpdate", It.IsAny <IEnumerable <SqlParameter> >()));
            mockSqlService.Setup(m => m.ExecuteNonQuery(It.IsAny <string>(), "rheRecentHistoryUpdate", It.IsAny <IEnumerable <SqlParameter> >()));
            mockSqlService.Setup(m => m.Execute <HistoryModel>(It.IsAny <string>(), "rheRecentHistoryGet", It.IsAny <IEnumerable <SqlParameter> >(), It.IsAny <Func <IDataReader, HistoryModel> >())).Returns(results);
            mockSqlService.Setup(m => m.Execute <HistoryModel>(It.IsAny <string>(), "rheRecentHistoryGetSingle", It.IsAny <IEnumerable <SqlParameter> >(), It.IsAny <Func <IDataReader, HistoryModel> >())).Returns(results);

            getResults = new Pageable <HistoryModel>(new PageMetadata());
            getResults.AddRange(results);

            //  mockMappingEngine.Setup(m => m.Map<IEnumerable<HistoryModel>, IPageable<HistoryModel>>(results)).Returns(getResults);
        }