Exemple #1
0
        public void ExecuteTestShouldRebuildWithReference()
        {
            File.Delete(TestUtility.TempDir + @"TestLibrary.dll");
            File.Delete(TestUtility.TempDir + @"TestApplication.exe");

            XmlDocument xdLib = new XmlDocument();

            xdLib.LoadXml(this.GetSample());
            XmlDocument xdExe = new XmlDocument();

            xdExe.LoadXml(this.GetSampleReference());

            // build TestLibrary.dll
            IAction cscLib = (IAction)BuildFileElementFactory.Create((XmlElement)xdLib.SelectSingleNode("//CSharp20Compiler"), null);

            ActionPropertySetter.SetProperties(cscLib);

            cscLib.Execute();
            Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestLibrary.dll"));

            // build TestAplication.exe
            IAction cscExe = (IAction)BuildFileElementFactory.Create((XmlElement)xdExe.SelectSingleNode("//CSharp20Compiler"), null);

            ActionPropertySetter.SetProperties(cscExe);

            cscExe.Execute();
            Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestApplication.exe"));

            // attempt to build TestApplication.exe again, verify that it is not rebuilt
            DateTime exeMod = File.GetLastWriteTime(TestUtility.TempDir + @"TestApplication.exe");

            IAction cscExe2 = (IAction)BuildFileElementFactory.Create((XmlElement)xdExe.SelectSingleNode("//CSharp20Compiler"), null);

            ActionPropertySetter.SetProperties(cscExe2);
            cscExe2.Execute();

            Assert.AreEqual(exeMod, File.GetLastWriteTime(TestUtility.TempDir + @"TestApplication.exe"));

            // delete TestLibrary, rebuild it
            File.Delete(TestUtility.TempDir + @"TestLibrary.dll");

            IAction cscLib2 = (IAction)BuildFileElementFactory.Create((XmlElement)xdLib.SelectSingleNode("//CSharp20Compiler"), null);

            ActionPropertySetter.SetProperties(cscLib2);
            cscLib2.Execute();

            // attempt to build TestApplication.exe again, verify that it is actually rebuilt
            IAction cscExe3 = (IAction)BuildFileElementFactory.Create((XmlElement)xdExe.SelectSingleNode("//CSharp20Compiler"), null);

            ActionPropertySetter.SetProperties(cscExe3);
            cscExe3.Execute();

            Assert.IsTrue(exeMod.CompareTo(File.GetLastWriteTime(TestUtility.TempDir + @"TestApplication.exe")) < 0);

            File.Delete(TestUtility.TempDir + @"TestLibrary.dll");
            File.Delete(TestUtility.TempDir + @"TestApplication.exe");
        }
Exemple #2
0
        public void GetInstanceTest()
        {
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(this.GetSample());

            IAction csc = (IAction)BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("//CSharp20Compiler"), null);

            Assert.AreEqual("\"C:\\Temp\\TestLibrary.dll\"", csc.Fields["out"]);
        }
Exemple #3
0
        public void ExecuteTestSourceFilesArg()
        {
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(this.GetSample());

            IAction csc = (IAction)BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("//CSharp20Compiler"), null);

            File.Delete(TestUtility.TempDir + @"TestLibrary.dll");

            csc.Execute();

            Assert.IsTrue(File.Exists(TestUtility.TempDir + @"TestLibrary.dll"));
            File.Delete(TestUtility.TempDir + @"TestLibrary.dll");
        }
Exemple #4
0
        public void ExecuteTest()
        {
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(this.GetSample());

            IAction jc = (IAction)BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("//Java15Compiler"), null);

            ActionPropertySetter.SetProperties(jc);

            File.Delete(TestUtility.TempDir + @"JavaApp.class");

            jc.Execute();

            Assert.IsTrue(File.Exists(TestUtility.TempDir + @"JavaApp.class"));

            // cleanup
            File.Delete(TestUtility.TempDir + @"JavaApp.class");
        }
Exemple #5
0
        public void TestIncompleteArgsExecute()
        {
            XmlDocument xd = new XmlDocument();

            xd.LoadXml(CommentReader.GetElement("sample"));

            IAction csc = (IAction)BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("//CSharp20Compiler"), null);

            ActionPropertySetter.SetProperties(csc);

            try
            {
                csc.Execute();
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is ActionNotExecutedException);
            }
        }
        public void Create()
        {
            XmlDocument xd = TestData.XmlDocument;
            BuildFile   bf = new BuildFile();

            bf.LoadXmlDocument(xd);

            IBuildFileElement elementAction = BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("/CamBuildProject/WriteConsole"), bf);

            Assert.IsTrue(elementAction.GetType().Name == "WriteConsole");
            Assert.AreEqual(elementAction.ParentBuildFile, bf);

            IBuildFileElement elementBuildComponent = BuildFileElementFactory.Create((XmlElement)xd.SelectSingleNode("/CamBuildProject/BuildComponent[@name='TestComponent']"), bf);

            Assert.IsTrue(elementBuildComponent is BuildComponent);
            Assert.AreEqual("TestComponent", ((BuildComponent)elementBuildComponent).Name);
            Assert.AreEqual(elementBuildComponent.ParentBuildFile, bf);

            IBuildFileElement elementProperty = BuildFileElementFactory.Create((XmlElement)xd.GetElementsByTagName("Property")[0], bf);

            Assert.AreEqual("Property", elementProperty.GetType().Name);
            Assert.AreEqual("OutputDir", elementProperty.GetType().GetProperty("Name").GetValue(elementProperty, null).ToString());
            Assert.AreEqual(elementProperty.ParentBuildFile, bf);
        }