Example #1
0
        public void ValidateStringMatch()
        {
            var aBuild   = CreateJavaScriptProject("project-A", "build");
            var aTest    = CreateJavaScriptProject("project-A", "test");
            var bBuild   = CreateJavaScriptProject("project-B", "build");
            var selector = new JavaScriptProjectSelector(new[] { aBuild, aTest, bBuild });

            var result = selector.GetMatches("project-A");

            XAssert.Contains(result, aBuild, aTest);
            XAssert.ContainsNot(result, bBuild);
        }
Example #2
0
        public void ValidateRegexMatch(string packageName, string commands, int expectedProjectCount)
        {
            var aBuild = CreateJavaScriptProject("project-A", "build");
            var aTest  = CreateJavaScriptProject("project-A", "test");
            var aLint  = CreateJavaScriptProject("project-A", "lint");
            var bTest  = CreateJavaScriptProject("project-B", "test");
            var bLint  = CreateJavaScriptProject("project-B", "lint");

            var selector = new JavaScriptProjectSelector(new[] { aBuild, aTest, aLint, bTest, bLint });

            var result = selector.GetMatches(new JavaScriptProjectRegexSelector()
            {
                PackageNameRegex = packageName, CommandRegex = commands
            });

            XAssert.AreEqual(expectedProjectCount, result.Count);
        }
Example #3
0
        public void ValidateSimpleMatch(string packageName, string[] commands, int expectedProjectCount)
        {
            var aBuild = CreateJavaScriptProject("project-A", "build");
            var aTest  = CreateJavaScriptProject("project-A", "test");
            var aLint  = CreateJavaScriptProject("project-A", "lint");
            var bLint  = CreateJavaScriptProject("project-B", "lint");

            var selector = new JavaScriptProjectSelector(new[] { aBuild, aTest, aLint, bLint });

            var result = selector.GetMatches(new JavaScriptProjectSimpleSelector()
            {
                PackageName = packageName, Commands = commands
            });

            XAssert.AreEqual(expectedProjectCount, result.Count);
            XAssert.IsTrue(result.All(project => project.Name == packageName));
            XAssert.IsTrue(result.All(project => commands?.Contains(project.ScriptCommandName) != false));
        }