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.
42 lines
1022 B
42 lines
1022 B
using System;
|
|
using System.Reactive.Linq;
|
|
using System.Threading.Tasks;
|
|
using Avalonia.Data;
|
|
using Avalonia.Data.Core;
|
|
using Avalonia.Markup.Parsers;
|
|
using Xunit;
|
|
|
|
namespace Avalonia.Base.UnitTests.Data.Core
|
|
{
|
|
public class ExpressionObserverTests_Negation
|
|
{
|
|
[Fact]
|
|
public async Task Should_Negate_Boolean_Value()
|
|
{
|
|
var data = new { Foo = true };
|
|
var target = ExpressionObserver.Create(data, o => !o.Foo);
|
|
var result = await target.Take(1);
|
|
|
|
Assert.False((bool)result);
|
|
|
|
GC.KeepAlive(data);
|
|
}
|
|
|
|
[Fact]
|
|
public void Can_SetValue_For_Valid_Value()
|
|
{
|
|
var data = new Test { Foo = true };
|
|
var target = ExpressionObserver.Create(data, o => !o.Foo);
|
|
target.Subscribe(_ => { });
|
|
|
|
Assert.True(target.SetValue(true));
|
|
|
|
Assert.False(data.Foo);
|
|
}
|
|
|
|
private class Test
|
|
{
|
|
public bool Foo { get; set; }
|
|
}
|
|
}
|
|
}
|
|
|