// // CodeTaskFactoryTest.cs // // Author: // Atsushi Enomoto // // Copyright (C) 2014 Xamarin Inc. // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; using System.IO; using System.Linq; using System.Xml; using Microsoft.Build.Framework; using Microsoft.Build.Tasks; using NUnit.Framework; using Microsoft.Build.Construction; using Microsoft.Build.Evaluation; using Microsoft.Build.Logging; namespace MonoTests.Microsoft.Build.Tasks { [TestFixture] public class CodeTaskFactoryTest { [Test] public void EmptyFactory () { var f = new CodeTaskFactory (); Assert.AreEqual ("Code Task Factory", f.FactoryName, "Name"); Assert.IsNull (f.TaskType, "TaskType"); Assert.IsNull (f.CreateTask (null), "CreateTask"); } [Test] public void Hello () { string project_xml = @" "; var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml))); root.FullPath = "CodeTaskFactoryTest.Hello.proj"; var project = new Project (root); Assert.IsTrue (project.Build (new ConsoleLogger (LoggerVerbosity.Diagnostic)), "Build"); } [Test] public void HelloWithParameter () { string project_xml = @" "; var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml))); root.FullPath = "CodeTaskFactoryTest.HelloWithParameter.proj"; var project = new Project (root); Assert.IsTrue (project.Build (new ConsoleLogger (LoggerVerbosity.Diagnostic)), "Build"); } [Test] public void Reference () { string project_xml = @" "; var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml))); root.FullPath = "CodeTaskFactoryTest.Reference.proj"; var project = new Project (root); Assert.IsTrue (project.Build (new ConsoleLogger (LoggerVerbosity.Diagnostic)), "Build"); } [Test] public void MultipleCodeElements () { string project_xml = @" "; var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml))); root.FullPath = "CodeTaskFactoryTest.MultipleCodeElements.proj"; var project = new Project (root); Assert.IsFalse (project.Build (), "Build"); } [Test] public void InvalidLanguage () { string project_xml = @" "; var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml))); root.FullPath = "CodeTaskFactoryTest.InvalidLanguage.proj"; var project = new Project (root); Assert.IsFalse (project.Build (), "Build"); } [Test] public void InvalidCSharp () { string project_xml = @" ""Hello, world!"" "; var root = ProjectRootElement.Create (XmlReader.Create (new StringReader (project_xml))); root.FullPath = "CodeTaskFactoryTest.InvalidCSharp.proj"; var project = new Project (root); Assert.IsFalse (project.Build (), "Build"); } } }