public void Invalid_Switch_Is_Invalid()
        {
            // Arrange
            var invalidComamndLineSwitch = string.Format("/XXX");

            var commandLineArguments = new Mock<ICommandLineArguments>();
            commandLineArguments.SetupSet(m => m.SuppressedWarnings = It.IsAny<IList<string>>()).Verifiable();

            var rule = new IsValidWarningSuppressionArgument(commandLineArguments.Object);

            // Act
            var isValid = rule.IsSatisfiedBy(new[] { invalidComamndLineSwitch });

            // Assert
            Assert.False(isValid);

            commandLineArguments.VerifySet(m => m.SuppressedWarnings = It.IsAny<IList<string>>(), Times.Never);
        }
        public void Single_Valid_Warning_Argument_Is_Recognised_Case_Insensitive()
        {
            // Arrange
            var expectedWarningsSuppressed = new[] { "ERROR" };
            var comamndLineSwitch = string.Format("/s{0}", string.Join(";", expectedWarningsSuppressed));

            var commandLineArguments = new Mock<ICommandLineArguments>();
            commandLineArguments.SetupSet(m => m.SuppressedWarnings = It.IsAny<IList<string>>()).Verifiable();

            var rule = new IsValidWarningSuppressionArgument(commandLineArguments.Object);

            // Act
            var isValid = rule.IsSatisfiedBy(new[] { comamndLineSwitch });

            // Assert
            Assert.True(isValid);

            commandLineArguments.VerifySet(m => m.SuppressedWarnings = It.Is<IList<string>>(l => l.SequenceEqual(expectedWarningsSuppressed)));
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArgumentRules"/> class.
        /// </summary>
        /// <param name="commandLineArguments">
        /// The command line arguments.
        /// </param>
        /// <param name="compilationLevelHelper">
        /// The compilation level helper.
        /// </param>
        public ArgumentRules(ICommandLineArguments commandLineArguments, ICompilationLevelHelper compilationLevelHelper)
        {
            Guard.ArgumentNotNull(() => commandLineArguments, commandLineArguments);
            Guard.ArgumentNotNull(() => compilationLevelHelper, compilationLevelHelper);

            // Setup validators
            var isValidJavaScriptFileName         = new IsValidJavaScriptFileName(commandLineArguments);
            var isValidCompilationLevelArgument   = new IsValidCompilationLevelArgument(commandLineArguments, compilationLevelHelper);
            var isValidWarningSuppressionArgument = new IsValidWarningSuppressionArgument(commandLineArguments);

            // Setup argument rule combos
            this.argumentRuleCombos.Add(
                new ArgumentRuleCombo(isValidJavaScriptFileName, isValidCompilationLevelArgument, isValidWarningSuppressionArgument));

            this.argumentRuleCombos.Add(
                new ArgumentRuleCombo(isValidJavaScriptFileName, isValidWarningSuppressionArgument));

            this.argumentRuleCombos.Add(
                new ArgumentRuleCombo(isValidJavaScriptFileName, isValidCompilationLevelArgument));

            this.argumentRuleCombos.Add(new ArgumentRuleCombo(isValidJavaScriptFileName));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ArgumentRules"/> class.
        /// </summary>
        /// <param name="commandLineArguments">
        /// The command line arguments.
        /// </param>
        /// <param name="compilationLevelHelper">
        /// The compilation level helper.
        /// </param>
        public ArgumentRules(ICommandLineArguments commandLineArguments, ICompilationLevelHelper compilationLevelHelper)
        {
            Guard.ArgumentNotNull(() => commandLineArguments, commandLineArguments);
            Guard.ArgumentNotNull(() => compilationLevelHelper, compilationLevelHelper);

            // Setup validators
            var isValidJavaScriptFileName = new IsValidJavaScriptFileName(commandLineArguments);
            var isValidCompilationLevelArgument = new IsValidCompilationLevelArgument(commandLineArguments, compilationLevelHelper);
            var isValidWarningSuppressionArgument = new IsValidWarningSuppressionArgument(commandLineArguments);

            // Setup argument rule combos
            this.argumentRuleCombos.Add(
                new ArgumentRuleCombo(isValidJavaScriptFileName, isValidCompilationLevelArgument, isValidWarningSuppressionArgument));

            this.argumentRuleCombos.Add(
                new ArgumentRuleCombo(isValidJavaScriptFileName, isValidWarningSuppressionArgument));

            this.argumentRuleCombos.Add(
                new ArgumentRuleCombo(isValidJavaScriptFileName, isValidCompilationLevelArgument));

            this.argumentRuleCombos.Add(new ArgumentRuleCombo(isValidJavaScriptFileName));
        }
 public void IsSatisfiedBy_Guards_Null_commandLineArguments()
 {
     var rule = new IsValidWarningSuppressionArgument(Mock.Of<ICommandLineArguments>());
     Assert.Throws<ArgumentNullException>(() => rule.IsSatisfiedBy(null));
 }