コード例 #1
0
        private void AssertConfigFileExists(AnalysisConfig config)
        {
            config.Should().NotBeNull("Supplied config should not be null");

            string.IsNullOrWhiteSpace(config.FileName).Should().BeFalse("Config file name should be set");
            File.Exists(config.FileName).Should().BeTrue("Expecting the analysis config file to exist. Path: {0}", config.FileName);

            TestContext.AddResultFile(config.FileName);
        }
コード例 #2
0
        [TestCategory("Task")] // Regression test for bug http://jira.codehaus.org/browse/SONARMSBRU-11
        public void TaskUtils_LoadConfig_RetryIfConfigLocked_ValueReturned()
        {
            // Arrange
            var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
            var configFile = CreateAnalysisConfig(testFolder);

            var logger = new TestLogger();

            AnalysisConfig result = null;

            PerformOpOnLockedFile(configFile, () => result = TaskUtilities.TryGetConfig(testFolder, logger), shouldTimeoutReadingConfig: false);

            result.Should().NotBeNull("Expecting the config to have been loaded");

            AssertRetryAttempted(logger);
            logger.AssertWarningsLogged(0);
            logger.AssertErrorsLogged(0);
        }
コード例 #3
0
        [TestCategory("Task")] // Regression test for bug http://jira.codehaus.org/browse/SONARMSBRU-11
        public void TaskUtils_LoadConfig_TimeoutIfConfigLocked_NullReturned()
        {
            // Arrange
            // We'll lock the file and sleep for long enough for the task to timeout
            var testFolder = TestUtils.CreateTestSpecificFolderWithSubPaths(TestContext);
            var configFile = CreateAnalysisConfig(testFolder);

            var logger = new TestLogger();

            AnalysisConfig result = null;

            PerformOpOnLockedFile(configFile, () => result = TaskUtilities.TryGetConfig(testFolder, logger), shouldTimeoutReadingConfig: true);

            result.Should().BeNull("Not expecting the config to be retrieved");

            AssertRetryAttempted(logger);
            logger.AssertWarningsLogged(0);
            logger.AssertErrorsLogged(1);
        }