Ejemplo n.º 1
0
        public void SimpleGeneration()
        {
            string capnpFile = "UnitTask1.capnp";
            string content   = LoadResourceContent(capnpFile);
            string tmpPath   = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(tmpPath);
            string capnpPath = Path.Combine(tmpPath, capnpFile);

            File.WriteAllText(capnpPath, content);

            var task = new GenerateCapnpFileCodeBehindTask();

            task.BuildEngine = new BuildEngineMock();
            task.ProjectPath = Path.Combine(tmpPath, "doesnotneedtoexist.csproj");
            task.CapnpFiles  = new ITaskItem[1] {
                new TaskItemMock()
                {
                    ItemSpec = capnpPath
                }
            };
            Assert.IsTrue(task.Execute());
            Assert.IsNotNull(task.GeneratedFiles);
            Assert.AreEqual(1, task.GeneratedFiles.Length);
            string csPath = Path.Combine(tmpPath, task.GeneratedFiles[0].ItemSpec);

            Assert.AreEqual(capnpPath + ".cs", csPath);
            Assert.IsTrue(File.Exists(csPath));
        }
Ejemplo n.º 2
0
        public void ExecutionWithoutParameters()
        {
            var task = new GenerateCapnpFileCodeBehindTask();

            task.BuildEngine = new BuildEngineMock();
            task.Execute();
            // Should not crash. Should Execute() return true or false if there is no input?
        }