Esempio n. 1
0
            public void TestXamlGenerator()
            {
                string xamlInputFile  = CreateXamlInputFile();
                string xamlOutputFile = IOPath.GetTempFileName();
                var    item           = new TaskItem(xamlInputFile);

                item.SetMetadata("TargetPath", xamlInputFile);

                string testAssemblyBinPath =
#if DEBUG
                    "Debug";
#else
                    "Release";
#endif

                var dir = IOPath.GetFullPath(
                    IOPath.Combine(
                        TestContext.CurrentContext.TestDirectory, "Xamarin.Forms.Controls.dll"));
                var xamlg = new XamlGTask()
                {
                    BuildEngine  = new DummyBuildEngine(),
                    AssemblyName = "test",
                    Language     = "C#",
                    XamlFiles    = new[] { item },
                    OutputFiles  = new[] { new TaskItem(xamlOutputFile) },
                    References   = dir
                };

                var generator = new XamlGenerator(item, xamlg.Language, xamlg.AssemblyName, xamlOutputFile, xamlg.References, null);
                Assert.IsTrue(generator.Execute());

                Assert.IsTrue(xamlg.Execute());
            }
Esempio n. 2
0
            public void TestXamlGenerator()
            {
                string xamlInputFile = CreateXamlInputFile();
                var    item          = new TaskItem(xamlInputFile);

                item.SetMetadata("TargetPath", xamlInputFile);

                string testAssemblyBinPath =
#if DEBUG
                    "Debug";
#else
                    "Release";
#endif

                var generator = new XamlGTask()
                {
                    BuildEngine  = new DummyBuildEngine(),
                    AssemblyName = "test",
                    Language     = "C#",
                    XamlFiles    = new[] { item },
                    OutputPath   = Path.GetDirectoryName(xamlInputFile),
                    References   = Path.GetFullPath(
                        Path.Combine(
                            Directory.GetCurrentDirectory(),
                            $@"..\..\..\Xamarin.Forms.Xaml.UnitTests.XmlnsDefinitionAttribute\bin\{testAssemblyBinPath}\netstandard2.0\Xamarin.Forms.Xaml.UnitTests.XmlnsDefinitionAttribute.dll"))
                };

                Assert.IsTrue(generator.Execute());
            }
Esempio n. 3
0
        public void XamlFileShouldNotBeLockedAfterFileIsGenerated()
        {
            string xamlInputFile  = CreateXamlInputFile();
            string xamlOutputFile = Path.ChangeExtension(xamlInputFile, ".xaml.g.cs");
            var    generator      = new XamlGTask();

            generator.BuildEngine  = new DummyBuildEngine();
            generator.AssemblyName = "Test";
            generator.Language     = "C#";

            generator.Execute(new TaskItem(xamlInputFile), xamlOutputFile);
            File.Delete(xamlOutputFile);

            Assert.DoesNotThrow(() => File.Delete(xamlInputFile));
        }
Esempio n. 4
0
		public void XamlFileShouldNotBeLockedAfterFileIsGenerated ()
		{
			string xamlInputFile = CreateXamlInputFile ();
			string xamlOutputFile = Path.ChangeExtension (xamlInputFile, ".xaml.g.cs");
			var generator = new XamlGTask ();
			generator.BuildEngine = new DummyBuildEngine ();
			generator.AssemblyName = "Test";
			generator.Source = xamlInputFile;
			generator.OutputFile = xamlOutputFile;
			generator.Language = "C#";

			generator.Execute();
			File.Delete (xamlOutputFile);

			Assert.DoesNotThrow (() => File.Delete (xamlInputFile));
		}
Esempio n. 5
0
        public void XamlGDifferentInputOutputLengths()
        {
            var engine    = new MSBuild.UnitTests.DummyBuildEngine();
            var generator = new XamlGTask()
            {
                BuildEngine  = engine,
                AssemblyName = "test",
                Language     = "C#",
                XamlFiles    = new ITaskItem[1],
                OutputFiles  = new ITaskItem[2],
            };

            Assert.IsFalse(generator.Execute(), "XamlGTask.Execute() should fail.");
            Assert.AreEqual(1, engine.Errors.Count, "XamlGTask should have 1 error.");
            var error = engine.Errors.First();

            Assert.AreEqual("\"XamlFiles\" refers to 1 item(s), and \"OutputFiles\" refers to 2 item(s). They must have the same number of items.", error.Message);
        }
		public void XamlFileShouldNotBeLockedAfterFileIsGenerated ()
		{
			string xamlInputFile = CreateXamlInputFile ();
			var item = new TaskItem(xamlInputFile);
			item.SetMetadata("TargetPath", xamlInputFile);
			var generator = new XamlGTask() {
				BuildEngine= new DummyBuildEngine(),
				AssemblyName = "test",
				Language = "C#",
				XamlFiles = new[] { item},
				OutputPath = Path.GetDirectoryName(xamlInputFile),
			};

			generator.Execute();

			string xamlOutputFile = generator.GeneratedCodeFiles.First().ItemSpec;
			File.Delete (xamlOutputFile);

			Assert.DoesNotThrow (() => File.Delete (xamlInputFile));
		}