static async Task<bool> IsMatchAsync(string documentText)
 {
     using (var builder = new WorkspaceBuilder())
     {
         return await Matcher.IsMatchAsync(builder.AddDocument(documentText));
     }
 }
        static async Task<bool> IsMatchAsync(string documentText, params string[] matchingAttributes)
        {
            using (var builder = new WorkspaceBuilder())
            {
                builder.ApplyOptions(
                    o => o.WithChangedOption(AttributeDocumentMatcher.AttributeNames, matchingAttributes));

                return await Matcher.IsMatchAsync(builder.AddDocument(documentText));
            }
        }
        static async Task<bool> IsMatchAsync(string projectName, string projectNameRegex)
        {
            using (var builder = new WorkspaceBuilder(projectName))
            {
                builder.ApplyOptions(
                    o => o.WithChangedOption(ProjectNameDocumentMatcher.ProjectNameRegex, projectNameRegex));

                return await Matcher.IsMatchAsync(builder.AddClass("Sample"));
            }
        }
        static async Task<bool> IsMatchAsync(string className, string directoryPath, string fileNameRegex)
        {
            using (var builder = new WorkspaceBuilder())
            {
                builder.ApplyOptions(
                    o => o.WithChangedOption(FilePathDocumentMatcher.FilePathRegex, fileNameRegex));

                return await Matcher.IsMatchAsync(builder.AddClass(className, directoryPath));
            }
        }
        public async Task StylizeEngineBasicScenarioTest()
        {
            using (var workspaceBuilder = new WorkspaceBuilder())
            {
                // For this test we will have three C# documents.
                string[] cSharpDocumentNames = new[]
                {
                    workspaceBuilder.AddClass("Class1").Name,
                    workspaceBuilder.AddClass("Class2").Name,
                    workspaceBuilder.AddClass("Class3").Name
                };

                // The exclusion matcher will match (exclude) the second document.
                isMatch = name => name.Equals(cSharpDocumentNames[1]);

                // Let's setup the onComponentExecuted delegate to capture executions
                var executions = new List<Tuple<Type, string>>();
                onComponentExecuted = (componentType, documentName) =>
                    executions.Add(Tuple.Create(componentType, documentName));

                var configParser = JsonConfigurationParser.FromString(JsonConfiguration);
                using (var engine = new StylizeEngine(configParser))
                {
                    await engine.RunAsync(workspaceBuilder.BuildWorkspace());
                }

                // Finally, let's assert on the executions.  In particular, we expect that the test matcher should
                // execute on all documents.  However, the test rules (TestRule2 then TestRule1 per ordering) should
                // only execute on the first and third C# documents because the matcher excluded the second.
                var expectedExecutions = new List<Tuple<Type, string>>
                {
                    Tuple.Create(typeof(TestMatcher), cSharpDocumentNames[0]),
                    Tuple.Create(typeof(TestRule2), cSharpDocumentNames[0]),
                    Tuple.Create(typeof(TestRule1), cSharpDocumentNames[0]),

                    Tuple.Create(typeof(TestMatcher), cSharpDocumentNames[1]),

                    Tuple.Create(typeof(TestMatcher), cSharpDocumentNames[2]),
                    Tuple.Create(typeof(TestRule2), cSharpDocumentNames[2]),
                    Tuple.Create(typeof(TestRule1), cSharpDocumentNames[2])
                };

                executions.Should().Equal(expectedExecutions, "Actual executions did not match expectations");
            }
        }