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
1.3 KiB
42 lines
1.3 KiB
// Copyright (c) The Perspex Project. All rights reserved.
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reactive.Linq;
|
|
using System.Reactive.Subjects;
|
|
using Xunit;
|
|
|
|
namespace Perspex.Styling.UnitTests
|
|
{
|
|
public class ActivatedValueTests
|
|
{
|
|
[Fact]
|
|
public void Should_Produce_Correct_Values()
|
|
{
|
|
var activator = new BehaviorSubject<bool>(false);
|
|
var target = new ActivatedValue(activator, 1, string.Empty);
|
|
var result = new List<object>();
|
|
|
|
target.Subscribe(x => result.Add(x));
|
|
|
|
activator.OnNext(true);
|
|
activator.OnNext(false);
|
|
|
|
Assert.Equal(new[] { PerspexProperty.UnsetValue, 1, PerspexProperty.UnsetValue }, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void Should_Complete_When_Activator_Completes()
|
|
{
|
|
var activator = new BehaviorSubject<bool>(false);
|
|
var target = new ActivatedValue(activator, 1, string.Empty);
|
|
var completed = false;
|
|
|
|
target.Subscribe(_ => { }, () => completed = true);
|
|
activator.OnCompleted();
|
|
|
|
Assert.True(completed);
|
|
}
|
|
}
|
|
}
|
|
|