示例#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");
        }
示例#2
0
        public void SetPropertiesTest()
        {
            XmlElement xe = (XmlElement)TestData.XmlDocument.SelectSingleNode("/CamBuildProject/WriteConsole");

            IAction ba = ActionFactory.Create(xe);

            Assert.AreEqual("WriteConsole", ba.GetType().Name);
            Assert.IsTrue(ba.Fields.ContainsKey("Message"));
            Assert.IsNull(ba.GetType().GetProperty("Message").GetValue(ba, null));

            ActionPropertySetter.SetProperties(ba);

            Assert.IsFalse(ba.Fields.ContainsKey("Message"));
            Assert.AreEqual("First test message", ba.GetType().GetProperty("Message").GetValue(ba, null).ToString());
        }
示例#3
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");
        }
示例#4
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);
            }
        }