Exemple #1
0
        public async Task TestGetImportedDatabases()
        {
            // Arrange
            var hostingEnvironment = HostingEnvironmentMocker.GetMockHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var logger             = LoggerMocker.GetLogger <DbController>();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var controller         = new DbController(logger, dbService);

            // Act
            var response = await controller.GetImportedDatabasesAsync() as ObjectResult;

            var value = response.Value as IListResponse <ImportedDatabase>;

            // Assert
            Assert.False(value.DidError);
        }
Exemple #2
0
        public async Task TestGetDatabaseDetailAsync()
        {
            // Arrange
            var hostingEnvironment = HostingEnvironmentMocker.GetMockHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var logger             = LoggerMocker.GetLogger <DbController>();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var controller         = new DbController(logger, dbService);
            var request            = new DbRequest
            {
                Name = "Store"
            };

            // Act
            var response = await controller.GetDatabaseDetailAsync(request) as ObjectResult;

            var value = response.Value as ISingleResponse <DatabaseDetail>;

            // Assert
            Assert.False(value.DidError);
        }
Exemple #3
0
        public async Task TestImportDatabase()
        {
            // Arrange
            var hostingEnvironment = HostingEnvironmentMocker.GetMockHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var logger             = LoggerMocker.GetLogger <DbController>();
            var controller         = new DbController(logger, dbService);
            var request            = new ImportDatabaseRequest
            {
                Name             = "Store",
                ConnectionString = "server=(local);database=Store;integrated security=yes;",
                ImportTables     = true,
                ImportViews      = true
            };

            // Act
            var response = await controller.ImportDatabaseAsync(request) as ObjectResult;

            var value = response.Value as ImportDatabaseResponse;

            // Assert
            Assert.False(value.DidError);
        }
Exemple #4
0
        public async Task TestEditDescriptionAsync()
        {
            // Arrange
            var hostingEnvironment = HostingEnvironmentMocker.GetMockHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var logger             = LoggerMocker.GetLogger <DbController>();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var controller         = new DbController(logger, dbService);
            var request            = new DbRequest
            {
                Name        = "Store",
                Table       = "Production.Product",
                Type        = "table",
                Description = "Products catalog (unit tests)"
            };

            // Act
            var response = await controller.EditDescriptionAsync(request) as ObjectResult;

            var value = response.Value as ISingleResponse <EditDescription>;

            // Assert
            Assert.False(value.DidError);
        }