blob: 4034ef5b1521b90f4ca0bc53261e876d468d4a0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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));
}
}
}
|