5 changed files with 64 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp3.1</TargetFramework> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="..\..\build\UnitTests.NetCore.targets" /> |
||||
|
<Import Project="..\..\build\Moq.props" /> |
||||
|
<Import Project="..\..\build\XUnit.props" /> |
||||
|
<Import Project="..\..\build\Rx.props" /> |
||||
|
<Import Project="..\..\build\Microsoft.Reactive.Testing.props" /> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml.Loader\Avalonia.Markup.Xaml.Loader.csproj" /> |
||||
|
<ProjectReference Include="..\Avalonia.UnitTests\Avalonia.UnitTests.csproj" /> |
||||
|
<ProjectReference Include="..\..\src\Avalonia.ReactiveUI.Events\Avalonia.ReactiveUI.Events.csproj" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -0,0 +1,44 @@ |
|||||
|
using System; |
||||
|
using System.Reactive.Linq; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.UnitTests; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Avalonia.ReactiveUI.Events.UnitTests |
||||
|
{ |
||||
|
public class BasicControlEventsTest |
||||
|
{ |
||||
|
public class EventsControl : UserControl |
||||
|
{ |
||||
|
public bool IsAttached { get; private set; } |
||||
|
|
||||
|
public EventsControl() |
||||
|
{ |
||||
|
var attached = this |
||||
|
.Events() |
||||
|
.AttachedToVisualTree |
||||
|
.Select(args => true); |
||||
|
|
||||
|
this.Events() |
||||
|
.DetachedFromVisualTree |
||||
|
.Select(args => false) |
||||
|
.Merge(attached) |
||||
|
.Subscribe(marker => IsAttached = marker); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public void Should_Generate_Events_Wrappers() |
||||
|
{ |
||||
|
var root = new TestRoot(); |
||||
|
var control = new EventsControl(); |
||||
|
Assert.False(control.IsAttached); |
||||
|
|
||||
|
root.Child = control; |
||||
|
Assert.True(control.IsAttached); |
||||
|
|
||||
|
root.Child = null; |
||||
|
Assert.False(control.IsAttached); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue