Example #1
0
        public static string SingleTextProcess(string input)
        {
            var identifierConverter = new CamelCaseIdentifierConverter();
            var generators          = ImmutableArray.Create <IGenerator>(
                new ConstructorGenerator(identifierConverter),
                new INotifyPropertyChangedGenerator(identifierConverter),
                new IEquatableGenerator());

            var testFileProvider = new TestFileProvider();

            testFileProvider.WriteAllTextOrSkip("Program.cs", input);

            var refAssembly       = typeof(object).Assembly.Location;
            var immutableAssembly = typeof(ImmutableArray <>).Assembly.Location;

            var processor = new Processor(testFileProvider, "Generated",
                                          ImmutableArray.Create("Program.cs"),
                                          ImmutableArray.Create(refAssembly, immutableAssembly), generators);

            processor.Process();

            return(testFileProvider.ReadAllText("Generated\\Program.g.cs"));
        }
Example #2
0
        public void ParseSwitch_FileListAsArguments_DistinguishGeneratedDirectoryOutputsFileInputFiles()
        {
            var args = new[]
            {
                "Generated",
                "Program.cs",
                "Sample/A.cs",
                "-r",
                "MyAssembly1.dll",
                "MyAssembly2.dll",
            };

            var testFileProvider = new TestFileProvider();
            var switchParser     = new SwitchParser(testFileProvider);
            var successResult    = switchParser.Parse(args) as SwitchParser.Result.Success;

            var switchInfo = successResult.SwitchInfo;

            Assert.Equal("Generated", switchInfo.GeneratedDirectory);
            Assert.Equal("Program.cs", switchInfo.InputFiles[0]);
            Assert.Equal("Sample/A.cs", switchInfo.InputFiles[1]);
            Assert.Equal("MyAssembly1.dll", switchInfo.ReferenceAssemblyFiles[0]);
            Assert.Equal("MyAssembly2.dll", switchInfo.ReferenceAssemblyFiles[1]);
        }