csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
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);
|
|
}
|
|
}
|
|
}
|
|
|