Ajax_when_getVisualisationData_is_true_and_chart_type_is_NOT_map_and_schema_definition_hasLatLngColumns_SETS_chartNumberToShow_value_from_WebConfig_if_null_andReturns_data_from_visualiseSchema () { //arrange string category = ""; string schema = ""; int? currentPage = null; int? numberToShow = null; string orderByColumn = ""; string orderByDirection = ""; IList <FilterCriteria> filter = new List <FilterCriteria>(); string download = ""; bool getVisualisationData = true; string chartType = ""; string xAxis = ""; string yAxis = ""; int chartCurrentPage = 1; int chartNumberToShow = 10; string yAxisAggregate = ""; DataSetSchema schemaDetail = new DataSetSchema() { Definition = new DataSetSchemaDefinition() { Columns = new List <DataSetSchemaColumn>() { new DataSetSchemaColumn() { ColumnName = "Latitude" }, new DataSetSchemaColumn() { ColumnName = "Longitude" } } } }; var mock = new Mock <IDataSetDetailService>(); mock.Setup(x => x.VisualiseSchema(filter, schemaDetail, 1, 10, chartType, xAxis, yAxis, yAxisAggregate)).Returns(new ViewControllerData() { DataGraph = "fromVisualiseSchema" }); _datasetDetailService = mock.Object; var mock2 = new Mock <IDataSetSchemaService>(); mock2.Setup(x => x.Get(schema)).Returns(schemaDetail); _dataSchemaService = mock2.Object; var sut = new ViewController(_dataSchemaService, _datasetDetailService, _categoryService, _sysConfigService); //action var result = (JsonResult)sut.Ajax(category, schema, currentPage, numberToShow, orderByColumn, orderByDirection, filter, download, getVisualisationData, chartType, xAxis, yAxis, chartCurrentPage, null, yAxisAggregate); var unboxedResult = (ViewControllerData)result.Data; //assert Assert.AreEqual(unboxedResult.DataGraph, "fromVisualiseSchema"); //cleanup }
Ajax_when_getVisualisationData_is_FALSE_returns_result_from_search_schema() { //arrange string category = ""; string schema = ""; int currentPage = 1; int numberToShow = 10; string orderByColumn = ""; string orderByDirection = ""; IList <FilterCriteria> filter = new List <FilterCriteria>(); string download = ""; bool getVisualisationData = false; string chartType = ""; string xAxis = ""; string yAxis = ""; int chartCurrentPage = 1; int chartNumberToShow = 10; string yAxisAggregate = ""; DataSetSchema schemaDetail = new DataSetSchema() { Definition = new DataSetSchemaDefinition() { Columns = new List <DataSetSchemaColumn>() { new DataSetSchemaColumn() { ColumnName = "Latitude" }, new DataSetSchemaColumn() { ColumnName = "Longitude" } } } }; var mock = new Mock <IDataSetDetailService>(); mock.Setup(x => x.SearchSchema(filter, schemaDetail, currentPage, numberToShow, orderByColumn, orderByDirection, true)).Returns(new ViewControllerData() { DataGraph = "fromSearchSchema" }); _datasetDetailService = mock.Object; var mock2 = new Mock <IDataSetSchemaService>(); mock2.Setup(x => x.Get(schema)).Returns(schemaDetail); _dataSchemaService = mock2.Object; var sut = new ViewController(_dataSchemaService, _datasetDetailService, _categoryService, _sysConfigService); //action var result = (JsonNetResult)sut.Ajax(category, schema, currentPage, numberToShow, orderByColumn, orderByDirection, filter, download, getVisualisationData, chartType, xAxis, yAxis, chartCurrentPage, null, yAxisAggregate); var unboxedResult = (ViewControllerData)result.Data; //assert Assert.AreEqual(unboxedResult.DataGraph, "fromSearchSchema"); //cleanup }