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"); } }
static void Main(string[] args) { using (var traceListener = new StylizeLogTraceListener()) { try { var options = new Options(); if (!Parser.Default.ParseArguments(args, options)) { return; } if (!File.Exists(options.ConfigFilePath)) { Log.WriteError($"Configuration file not found at: {options.ConfigFilePath}"); return; } if (!File.Exists(options.SolutionFilePath)) { Log.WriteError($"Solution file not found at: {options.SolutionFilePath}"); return; } traceListener.VerboseConsoleLogging = options.VerboseConsoleLogging; if (!String.IsNullOrEmpty(options.LogFilePath)) { traceListener.EnableLogFile(options.LogFilePath); } var configParser = JsonConfigurationParser.FromFile(options.ConfigFilePath); using (var engine = new StylizeEngine(configParser)) { engine.RunAsync(options.SolutionFilePath).Wait(); } } catch (Exception ex) { Log.WriteError($"Exception occurred: {ex}"); throw; } } }