-
-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from runceel/main
Release v7.12.0
- Loading branch information
Showing
14 changed files
with
248 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [neuecc, runceel] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
127 changes: 127 additions & 0 deletions
127
Test/ReactiveProperty.WPF.Tests/Interactivity/EventToReactiveCommandTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reactive.Concurrency; | ||
using System.Text; | ||
using System.Windows; | ||
using System.Windows.Input; | ||
using System.Linq; | ||
using Microsoft.Reactive.Testing; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
using Reactive.Bindings; | ||
using Reactive.Bindings.Interactivity; | ||
|
||
namespace ReactiveProperty.Tests.Interactivity | ||
{ | ||
[TestClass] | ||
public class EventToReactiveCommandTest | ||
{ | ||
[STATestMethod] | ||
public void Test_CallExecuteOnScheduler_TrueCase() | ||
{ | ||
var scheduler = new MockScheduler(); | ||
ReactivePropertyScheduler.SetDefault(scheduler); | ||
|
||
var commandArgument = new object(); | ||
var mockCommand = new Mock<ICommand>(); | ||
mockCommand.Setup(x => x.Execute(It.Is<object>(y => y == commandArgument))) | ||
.Verifiable(); | ||
mockCommand.Setup(x => x.CanExecute(It.IsAny<object>())) | ||
.Returns(true); | ||
|
||
var attachedTarget = new FrameworkElement(); | ||
var target = new EventToReactiveCommand | ||
{ | ||
Command = mockCommand.Object, | ||
}; | ||
target.Attach(attachedTarget); | ||
|
||
target.AsDynamic().Invoke(commandArgument); | ||
|
||
scheduler.CallHistory.Count.Is(1); | ||
mockCommand.VerifyAll(); | ||
} | ||
|
||
[STATestMethod] | ||
public void Test_CallExecuteOnScheduler_FalseCase() | ||
{ | ||
var scheduler = new MockScheduler(); | ||
ReactivePropertyScheduler.SetDefault(scheduler); | ||
|
||
var commandArgument = new object(); | ||
var mockCommand = new Mock<ICommand>(); | ||
mockCommand.Setup(x => x.Execute(It.Is<object>(y => y == commandArgument))) | ||
.Verifiable(); | ||
mockCommand.Setup(x => x.CanExecute(It.IsAny<object>())) | ||
.Returns(true); | ||
|
||
var attachedTarget = new FrameworkElement(); | ||
var target = new EventToReactiveCommand | ||
{ | ||
CallExecuteOnScheduler = false, | ||
Command = mockCommand.Object, | ||
}; | ||
target.Attach(attachedTarget); | ||
|
||
target.AsDynamic().Invoke(commandArgument); | ||
|
||
scheduler.CallHistory.Any().Is(false); | ||
mockCommand.VerifyAll(); | ||
} | ||
|
||
[STATestMethod] | ||
public void Test_CallExecuteOnScheduler_ChangePropertyAfterInitialized() | ||
{ | ||
var scheduler = new MockScheduler(); | ||
ReactivePropertyScheduler.SetDefault(scheduler); | ||
|
||
var commandArgument = new object(); | ||
var mockCommand = new Mock<ICommand>(); | ||
mockCommand.Setup(x => x.Execute(It.Is<object>(y => y == commandArgument))) | ||
.Verifiable(); | ||
mockCommand.Setup(x => x.CanExecute(It.IsAny<object>())) | ||
.Returns(true); | ||
|
||
var attachedTarget = new FrameworkElement(); | ||
var target = new EventToReactiveCommand | ||
{ | ||
CallExecuteOnScheduler = false, | ||
Command = mockCommand.Object, | ||
}; | ||
target.Attach(attachedTarget); | ||
|
||
target.CallExecuteOnScheduler = true; | ||
|
||
target.AsDynamic().Invoke(commandArgument); | ||
|
||
scheduler.CallHistory.Count.Is(1); | ||
mockCommand.VerifyAll(); | ||
} | ||
|
||
private class MockScheduler : IScheduler | ||
{ | ||
private readonly ImmediateScheduler _innerScheduler = ImmediateScheduler.Instance; | ||
public DateTimeOffset Now => _innerScheduler.Now; | ||
|
||
public List<object> CallHistory { get; } = new List<object>(); | ||
|
||
public IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action) | ||
{ | ||
CallHistory.Add(state); | ||
return _innerScheduler.Schedule(state, action); | ||
} | ||
|
||
public IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action) | ||
{ | ||
CallHistory.Add(state); | ||
return _innerScheduler.Schedule(state, dueTime, action); | ||
} | ||
|
||
public IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action) | ||
{ | ||
CallHistory.Add(state); | ||
return _innerScheduler.Schedule(state, dueTime, action); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.