public void Input_Should_Expect_Xaml(string input, string outputXaml)
        {
            var templator = new Templator();

            var result = templator.Generate(input, "Test").Last().Xaml.Content;

            result.Should().Contain(outputXaml);
        }
        public void Input_Should_Contain_CSharp(string input, string outputCSharp)
        {
            var templator = new Templator();

            templator.Generate(input, "Test").First().CSharp.Content.Should().Contain(outputCSharp);
            //var result2 = Regex.Replace(result, @"\s+", "");
            //Console.WriteLine(result);
            //result2.Should().Be(Regex.Replace(outputCSharp, @"\s+", ""));
        }
        public void EmbbedTypes_Should_Pass(string code)
        {
            var result = templator.Generate(code, "Example");

            foreach (var generatedType in result)
            {
                Console.WriteLine(generatedType.Xaml.Content);
                Console.WriteLine(generatedType.CSharp.Content);
            }
        }
Пример #4
0
        public override bool Execute()
        {
            try
            {
                var templator = new Templator();
                var files     = Directory.GetFiles(Directory.GetCurrentDirectory(), Filter);
                foreach (var file in files)
                {
                    Log.LogMessage(MessageImportance.High, $"Found file {file}");

                    var content = File.ReadAllText(file);

                    var result = templator.Generate(content, Namespace);

                    foreach (var generatedType in result)
                    {
                        Log.LogMessage(MessageImportance.High, $"Generated '{generatedType.CSharp.FileName}'");
                        Log.LogMessage(MessageImportance.High, $"Generated '{generatedType.Xaml.FileName}'");

                        var x = generatedType.Xaml;
                        var c = generatedType.CSharp;

                        var directory = Path.Combine(Directory.GetCurrentDirectory(), Folder);

                        if (Directory.Exists(directory) != true)
                        {
                            Directory.CreateDirectory(directory);
                        }

                        File.WriteAllText(Path.Combine(directory, x.FileName), x.Content);
                        File.WriteAllText(Path.Combine(directory, c.FileName), c.Content);
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogErrorFromException(e);
                return(false);
            }

            return(true);
        }
 public void IdWithNumber_Should_Pass()
 {
     templator.Generate(codeWithNumberId, "test");
 }
        public void Output_Should_NOTContainXaml(string code, string xaml)
        {
            var templator = new Templator();

            templator.Generate(code, "Test").First().Xaml.Content.Should().NotContain(xaml);
        }
        public void Output_Should_NOTContainCSharp(string code, string csharp)
        {
            var templator = new Templator();

            templator.Generate(code, "Test").First().CSharp.Content.Should().NotContain(csharp);
        }
        public void Code_Should_ThrowCompileException(string code)
        {
            var tem = new Templator();

            Assert.Throws <CompileException>(() => tem.Generate(code, "test"));
        }