public void Checkers_AreAppliedCorrectly()
        {
            // Arrange
            var repoWarning = new CheckerMessage("some repo warning");

            IChecker[] checkers = { new TestChecker(() => new[] { repoWarning }) };

            var platformVersion = "1.0.0";
            var detector        = new TestLanguageDetectorSimpleMatch(true, TestPlatformName, platformVersion);
            var platform        = new TestProgrammingPlatform(
                TestPlatformName, new[] { platformVersion }, true, "script-content", detector);

            var generator = CreateDefaultScriptGenerator(new[] { platform }, checkers);
            var context   = CreateScriptGeneratorContext(TestPlatformName, platformVersion);

            var messages = new List <ICheckerMessage>();

            // Act
            // Return value of TryGenerateBashScript is irrelevant - messages should be added even if build fails
            generator.GenerateBashScript(context, out var generatedScript, messages);

            // Assert
            Assert.Single(messages);
            Assert.Equal(repoWarning, messages.First());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new <see cref="CheckerMessage"/> to the report.
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when a null message is given.</exception>
        /// <param name="message">The new <see cref="CheckerMessage"/>.</param>
        public void Add(CheckerMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            this.checkerMessages.Add(message);
        }
Exemplo n.º 3
0
        public void Add_ShouldThrowAnExceptionIfNullIsGiven()
        {
            var                    checkerReport         = new CheckerReport();
            CheckerMessage         nullMessage           = null;
            IList <CheckerMessage> nullMessageCollection = null;

            Assert.Throws <ArgumentNullException>(() => checkerReport.Add(nullMessageCollection));

            Assert.Throws <ArgumentNullException>(() => checkerReport.Add(nullMessage));
        }