summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests/XamlgFileLockTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests/XamlgFileLockTests.cs')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlgFileLockTests.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/XamlgFileLockTests.cs b/Xamarin.Forms.Xaml.UnitTests/XamlgFileLockTests.cs
new file mode 100644
index 00000000..4034ef5b
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/XamlgFileLockTests.cs
@@ -0,0 +1,43 @@
+using System;
+using System.IO;
+using NUnit.Framework;
+using Xamarin.Forms.Build.Tasks;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ [TestFixture]
+ public class XamlgFileLockTests : BaseTestFixture
+ {
+ string CreateXamlInputFile ()
+ {
+ string xaml =
+ @"<ContentPage xmlns='http://xamarin.com/schemas/2014/forms' xmlns:x='http://schemas.microsoft.com/winfx/2009/xaml' x:Class='Test.MyPage'>
+ <ContentPage.Content></ContentPage.Content>
+ </ContentPage>";
+
+ string fileName = Path.GetTempFileName ();
+ File.WriteAllText (fileName, xaml);
+
+ return fileName;
+ }
+
+ [Test]
+ 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));
+ }
+ }
+} \ No newline at end of file