-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
XamlgFileLockTests.cs
50 lines (43 loc) · 1.33 KB
/
XamlgFileLockTests.cs
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
44
45
46
47
48
49
50
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.Forms.Build.Tasks;
using Xamarin.Forms.Core.UnitTests;
using Microsoft.Build.Utilities;
using IOPath = System.IO.Path;
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 = IOPath.GetTempFileName ();
File.WriteAllText (fileName, xaml);
return fileName;
}
[Test]
public void XamlFileShouldNotBeLockedAfterFileIsGenerated ()
{
string xamlInputFile = CreateXamlInputFile ();
var item = new TaskItem(xamlInputFile);
item.SetMetadata("TargetPath", xamlInputFile);
var generator = new XamlGTask() {
BuildEngine= new MSBuild.UnitTests.DummyBuildEngine(),
AssemblyName = "test",
Language = "C#",
XamlFiles = new[] { item },
OutputFiles = new[] { new TaskItem(xamlInputFile + ".g.cs") }
};
generator.Execute();
string xamlOutputFile = generator.OutputFiles.First().ItemSpec;
File.Delete (xamlOutputFile);
Assert.DoesNotThrow (() => File.Delete (xamlInputFile));
}
}
}