Exemple #1
0
        public void SearchSchema_will_return_view_controller_data_object_with_total_pages_if_not_zero_will_return_value_of_total_pages()
        {
            //arrange
            IList <FilterCriteria> filter = null;
            DataSetSchema          schema = null;
            int    currentPage            = 0;
            int    pageSize       = 10;
            string orderByColumn  = "";
            string orderDirection = "DESC";
            bool   getTotals      = false;
            var    ds             = new DataSet();

            ds.Tables.Add(ReturnDataTable(null, 50));
            ds.Tables.Add(new DataTable());
            ds.Tables.Add(new DataTable());
            var mock = new Mock <IDataSetDetailSqlRepo>();

            mock.Setup(
                x =>
                x.ExecuteQuerySearchSchema(_repositoryDataSetDetail.DbConnectionString, filter, schema, currentPage,
                                           pageSize, orderByColumn, orderDirection)).Returns(ds);
            _sqlRepo = mock.Object;
            var sut = new DataSetDetailService(_systemConfigurationService, _repositoryDataSetDetail, _dataSetSchemaService, _sqlRepo, _sqlColumnTextFormatter);
            //act
            var result = sut.SearchSchema(filter, schema, currentPage, pageSize, orderByColumn, orderDirection, getTotals);

            //assert
            Assert.AreEqual(5, result.TotalPages);
            //cleanup
        }
Exemple #2
0
        public void SearchSchema_when_orderdirection_is_null_empty_will_set_order_direction_to_asc()
        {
            //arrange

            IList <FilterCriteria> filter = null;
            DataSetSchema          schema = null;
            int    currentPage            = 0;
            int    pageSize       = 10;
            string orderByColumn  = "";
            string orderDirection = "ASC";
            bool   getTotals      = false;
            var    mock           = new Mock <IDataSetDetailSqlRepo>();
            var    ds             = new DataSet();

            ds.Tables.Add(ReturnDataTable(null, 2));
            ds.Tables.Add(new DataTable());
            ds.Tables.Add(new DataTable());
            mock.Setup(
                x =>
                x.ExecuteQuerySearchSchema(_repositoryDataSetDetail.DbConnectionString, filter, schema, currentPage,
                                           pageSize, orderByColumn, orderDirection)).Returns(ds);
            _sqlRepo = mock.Object;
            var sut = new DataSetDetailService(_systemConfigurationService, _repositoryDataSetDetail, _dataSetSchemaService, _sqlRepo, _sqlColumnTextFormatter);
            //act
            var result = sut.SearchSchema(filter, schema, currentPage, pageSize, orderByColumn, "", getTotals);

            //assert
            Assert.AreEqual(2, result.Count);
            //cleanup
        }