committed by
GitHub
4 changed files with 104 additions and 2 deletions
@ -0,0 +1,52 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.Markup.Xaml.UnitTests |
||||
|
{ |
||||
|
public class StyleIncludeTests : XamlTestBase |
||||
|
{ |
||||
|
[Fact] |
||||
|
public void Missing_ResourceKey_In_StyleInclude_Does_Not_Cause_StackOverflow() |
||||
|
{ |
||||
|
var styleXaml = @"
|
||||
|
<Style xmlns='https://github.com/avaloniaui'
|
||||
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
||||
|
<Style.Resources> |
||||
|
<StaticResource x:Key='brush' ResourceKey='missing' /> |
||||
|
</Style.Resources> |
||||
|
</Style>";
|
||||
|
|
||||
|
using (StartWithResources(("test:style.xaml", styleXaml))) |
||||
|
{ |
||||
|
var xaml = @"
|
||||
|
<Application xmlns='https://github.com/avaloniaui'
|
||||
|
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>
|
||||
|
<Application.Styles> |
||||
|
<StyleInclude Source='test:style.xaml'/> |
||||
|
</Application.Styles> |
||||
|
</Application>";
|
||||
|
|
||||
|
var loader = new AvaloniaXamlLoader(); |
||||
|
var app = Application.Current; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
loader.Load(xaml, null, app); |
||||
|
} |
||||
|
catch (KeyNotFoundException) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private IDisposable StartWithResources(params (string, string)[] assets) |
||||
|
{ |
||||
|
var assetLoader = new MockAssetLoader(assets); |
||||
|
var services = new TestServices(assetLoader: assetLoader); |
||||
|
return UnitTestApplication.Start(services); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue