Ejemplo n.º 1
0
        public async Task ActivityDocumentation_WhenDocumentationTypeIsIncorrect_ReturnsBadRequest()
        {
            var controller = new DocumentationController(_activityMock.Object, _terminalMock.Object);
            var result     = await controller.Activity(new ActivityDTO { Documentation = "something" });

            Assert.IsTrue(result is BadRequestErrorMessageResult, "Wrong result type is returned for incorrect documentation type");
        }
Ejemplo n.º 2
0
        public async Task ActivityDocumentation_WhenDocumentationIsForMainPage_ReturnsSolutionDocumentation()
        {
            var controller = new DocumentationController(_activityMock.Object, _terminalMock.Object);
            var result     = await controller.Activity(new ActivityDTO { Documentation = "MainPage" });

            Assert.IsTrue(result is OkNegotiatedContentResult <DocumentationResponseDTO>, "Wrong result type is returned for solution documentation type");
            _activityMock.Verify(x => x.GetActivityDocumentation <DocumentationResponseDTO>(It.IsAny <ActivityDTO>(), true), Times.Once(), "Solution documentation was not requested");
        }
Ejemplo n.º 3
0
        public async Task ActivityDocumentation_WhenDocumentationIsForTerminal_ReturnsSolutionsDocumentations()
        {
            var controller = new DocumentationController(_activityMock.Object, _terminalMock.Object);
            var result     = await controller.Activity(new ActivityDTO { Documentation = "Terminal=t" });

            Assert.IsTrue(result is OkNegotiatedContentResult <List <DocumentationResponseDTO> >, "Wrong result type is returned for terminal documentation type");
            _terminalMock.Verify(x => x.GetSolutionDocumentations("t"), Times.Once(), "Terminal documentation was not requested");
        }
        public async Task TestGetImportedDatabases()
        {
            // Arrange
            var logger             = LoggingHelper.GetLogger <DocumentationController>();
            var hostingEnvironment = HostingEnvironmentMocker.GetHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var controller         = new DocumentationController(logger, dbService);

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

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

            // Assert
            Assert.False(value.DidError);
        }
        public async Task TestGetDatabaseDetailAsync()
        {
            // Arrange
            var logger             = LoggingHelper.GetLogger <DocumentationController>();
            var hostingEnvironment = HostingEnvironmentMocker.GetHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var controller         = new DocumentationController(logger, dbService);
            var request            = new DbRequest
            {
                Name = "OnlineStore"
            };

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

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

            // Assert
            Assert.False(value.DidError);
        }
        public async Task TestImportDatabase()
        {
            // Arrange
            var logger             = LoggingHelper.GetLogger <DocumentationController>();
            var hostingEnvironment = HostingEnvironmentMocker.GetHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var controller         = new DocumentationController(logger, dbService);
            var request            = new ImportDatabaseRequest
            {
                Name             = "OnlineStore",
                ConnectionString = "server=(local);database=OnlineStore;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);
        }
        public async Task TestEditDescriptionAsync()
        {
            // Arrange
            var hostingEnvironment = HostingEnvironmentMocker.GetHostingEnvironment();
            var apiConfig          = new ApiConfig();
            var dbService          = new DbService(hostingEnvironment, apiConfig);
            var logger             = LoggingHelper.GetLogger <DocumentationController>();
            var controller         = new DocumentationController(logger, dbService);
            var request            = new DbRequest
            {
                Name        = "OnlineStore",
                Table       = "Warehouse.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);
        }
 public void SetUp()
 {
     _mockVersionProvider     = new Mock <IVersionProvider>();
     _documentationController = new DocumentationController(_mockVersionProvider.Object);
 }