Ejemplo n.º 1
0
        private static async Task <IDictionary <string, string> > PackagingFilesAsync(string name, IPreprocessedRule preprocessedRule)
        {
            var inMemoryFiles = new Dictionary <string, string>
            {
                { $"{name}.rule", string.Join(Environment.NewLine, RuleFileParser.Write(preprocessedRule)) }
            };

            var assembly = Assembly.GetExecutingAssembly();

            // TODO we can deserialize a KuduFunctionConfig instead of using a fixed file...
            using (var stream = assembly.GetManifestResourceStream("aggregator.cli.Rules.function.json"))
            {
                using (var reader = new StreamReader(stream))
                {
                    var content = await reader.ReadToEndAsync();

                    inMemoryFiles.Add("function.json", content);
                }
            }

            using (var stream = assembly.GetManifestResourceStream("aggregator.cli.Rules.run.csx"))
            {
                using (var reader = new StreamReader(stream))
                {
                    var content = await reader.ReadToEndAsync();

                    inMemoryFiles.Add("run.csx", content);
                }
            }

            return(inMemoryFiles);
        }
        public void RuleLanguageReadWrite_Succeeds(string ruleCode)
        {
            var mincedCode = ruleCode.Mince();

            (IPreprocessedRule ppRule, _) = RuleFileParser.Read(mincedCode);

            var ruleCode2 = RuleFileParser.Write(ppRule);

            Assert.Equal(mincedCode, ruleCode2, StringComparer.OrdinalIgnoreCase);
        }
Ejemplo n.º 3
0
        private static async Task <IDictionary <string, string> > PackagingFilesAsync(string ruleName, IPreprocessedRule preprocessedRule)
        {
            var inMemoryFiles = new Dictionary <string, string>
            {
                { $"{ruleName}.rule", string.Join(Environment.NewLine, RuleFileParser.Write(preprocessedRule)) }
            };

            //var assembly = Assembly.GetExecutingAssembly();
            //await inMemoryFiles.AddFunctionDefaultFiles(assembly);

            return(inMemoryFiles);
        }
Ejemplo n.º 4
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        private static async Task <IDictionary <string, string> > PackagingFilesAsync(string ruleName, IPreprocessedRule preprocessedRule)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        {
            var inMemoryFiles = new Dictionary <string, string>
            {
                { $"{ruleName}.rule", string.Join(Environment.NewLine, RuleFileParser.Write(preprocessedRule)) }
            };

            //var assembly = Assembly.GetExecutingAssembly();
            //await inMemoryFiles.AddFunctionDefaultFiles(assembly);

            return(inMemoryFiles);
        }
Ejemplo n.º 5
0
        public void RuleLanguageReadWrite_Succeeds()
        {
            string ruleCode = @".language=C#
.reference=System.Xml.XDocument
.import=System.Diagnostics

return $""Hello { self.WorkItemType } #{ self.Id } - { self.Title }!"";
";

            var mincedCode = ruleCode.Mince();

            (IPreprocessedRule ppRule, _) = RuleFileParser.Read(mincedCode);

            var ruleCode2 = RuleFileParser.Write(ppRule);

            Assert.Equal(mincedCode, ruleCode2, StringComparer.OrdinalIgnoreCase);
        }