public void Rule_Is_Satisfied_By_Valid_Js_File_Name()
        {
            // Arrange
            var commandLineArguments = new Mock<ICommandLineArguments>();
            var rule = new IsValidJavaScriptFileName(commandLineArguments.Object);
            var args = new[] { "JSFILE.JS" };

            // Act
            var isSatisfiedBy = rule.IsSatisfiedBy(args);

            // Assert
            Assert.True(isSatisfiedBy);
        }
        public void Rule_Is_Not_Satisfied_When_Invalid_Js_File_Name_Is_Passed()
        {
            // Arrange
            var commandLineArguments = new Mock<ICommandLineArguments>();
            var rule = new IsValidJavaScriptFileName(commandLineArguments.Object);
            var args = new[] { "JsFile.ps" };

            // Act
            var isSatisfiedBy = rule.IsSatisfiedBy(args);

            // Assert
            Assert.False(isSatisfiedBy);
        }
        public void Command_Line_Arguments_FileName_Is_Set()
        {
            // Arrange
            var expectedFileName = "JSFILE.JS";
            var commandLineArguments = new Mock<ICommandLineArguments>();
            var rule = new IsValidJavaScriptFileName(commandLineArguments.Object);
            var args = new[] { expectedFileName };

            // Act
            rule.IsSatisfiedBy(args);

            // Assert
            commandLineArguments.VerifySet(m => m.FileName = expectedFileName);
        }
Example #4
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 IsValidJavaScriptFileName(Mock.Of<ICommandLineArguments>());
     Assert.Throws<ArgumentNullException>(() => rule.IsSatisfiedBy(null));
 }
        public void Rule_Is_Satisfied_By_Valid_Js_File_Name_Regardless_Of_Captial_Casing()
        {
            // Arrange
            var commandLineArguments = new Mock<ICommandLineArguments>();
            var rule = new IsValidJavaScriptFileName(commandLineArguments.Object);
            var args = new[] { "jsfile.js" };

            // Act
            var isSatisfiedBy = rule.IsSatisfiedBy(args);

            // Assert
            Assert.True(isSatisfiedBy);
        }