Beispiel #1
0
        public void GetData_when_datasetdetail_is_null_returns_null()
        {
            //arrange
            var sut = new DataSetDetailService(_systemConfigurationService, _repositoryDataSetDetail, _dataSetSchemaService, _sqlRepo, _sqlColumnTextFormatter);
            //act
            var result = sut.GetData("emptyurl", "emptyschemaurl");

            //assert
            Assert.AreEqual(null, result);
            //cleanup
        }
Beispiel #2
0
        public void GetData_when_datasetdetail_is_not_null_returns_datatable()
        {
            //arrange
            var datasetdetail = new DataSetDetail()
            {
                Title = "datasetdetail title here", Schema = new DataSetSchema()
                {
                    Title = "schema title here", Definition = new DataSetSchemaDefinition()
                    {
                        TableName = "table1", Columns = new List <DataSetSchemaColumn>()
                        {
                            new DataSetSchemaColumn()
                            {
                                Title = "col1"
                            }
                        }
                    }
                }
            };

            _repositoryDataSetDetail.Add(datasetdetail);
            var ds = new DataSet();

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

            mock.Setup(x => x.ExecuteQueryDatasetDetailId(_repositoryDataSetDetail.DbConnectionString, datasetdetail.Schema.Definition, datasetdetail.Id)).Returns(ds);
            _sqlRepo = mock.Object;
            var sut = new DataSetDetailService(_systemConfigurationService, _repositoryDataSetDetail, _dataSetSchemaService, _sqlRepo, _sqlColumnTextFormatter);
            //act
            var result = sut.GetData("datasetdetail-title-here", "schema-title-here");

            //assert
            Assert.AreEqual(typeof(DataTable), result.GetType());
            //cleanup
        }