Exemple #1
0
        public async Task Fetch_Datasource_In_Mongo_Test()
        {
            if (!_context.AllowMongoDB)
            {
                Assert.True(true);
                return;
            }
            // Arrange
            Mock <IDatabaseServiceProvider> mockDatabaseServiceProvider = new Mock <IDatabaseServiceProvider>();

            mockDatabaseServiceProvider
            .Setup(a => a.GetOneDatabaseConnectionAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(_context.MongoDatabaseConenction));

            MongoExtractionDatasource mongoExtractionDatasource = new MongoExtractionDatasource();
            DatasourceService         datasourceService         = new DatasourceService(mockDatabaseServiceProvider.Object, new IExtractionDatasource[] { mongoExtractionDatasource });

            // Act
            LetPortal.Portal.Models.ExecutedDataSourceModel result = await datasourceService.GetDatasourceService(new Datasource
            {
                DatabaseId     = "aaa",
                DatasourceType = DatasourceType.Database,
                Query          = "{\r\n  \"databases\": { \"name\" : \"testdatabase\" }\r\n}"
            });

            // Assert
            Assert.NotEmpty(result.DatasourceModels);
        }
Exemple #2
0
        public async Task Fetch_Datasource_In_Postgre_Test()
        {
            if (!_context.AllowPostgreSQL)
            {
                Assert.True(true);
                return;
            }
            // Arrange
            Mock <IDatabaseServiceProvider> mockDatabaseServiceProvider = new Mock <IDatabaseServiceProvider>();

            mockDatabaseServiceProvider
            .Setup(a => a.GetOneDatabaseConnectionAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(_context.PostgreSqlDatabaseConnection));

            PostgreExtractionDatasource postgreExtractionDatasource = new PostgreExtractionDatasource();
            DatasourceService           datasourceService           = new DatasourceService(mockDatabaseServiceProvider.Object, new IExtractionDatasource[] { postgreExtractionDatasource });

            // Act
            LetPortal.Portal.Models.ExecutedDataSourceModel result = await datasourceService.GetDatasourceService(new Datasource
            {
                DatabaseId     = "aaa",
                DatasourceType = DatasourceType.Database,
                Query          = "Select \"name\", \"id\" as \"Value\" from databases"
            });

            // Assert
            Assert.NotEmpty(result.DatasourceModels);
        }
Exemple #3
0
        public async Task Fetch_Datasource_In_Static_Json_Test()
        {
            // Arrange
            DatasourceService datasourceService = new DatasourceService(null, null);

            // Act
            LetPortal.Portal.Models.ExecutedDataSourceModel result = await datasourceService.GetDatasourceService(new Datasource
            {
                DatasourceType = DatasourceType.Static,
                Query          = "[{\"name\":\"MongoDB\",\"value\":\"mongodb\"},{\"name\":\"SQL Server\",\"value\":\"sqlserver\"}]"
            });

            // Assert
            Assert.NotEmpty(result.DatasourceModels);
        }