2020-07-03 04:48:41 +08:00
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Wox.Plugin;
|
2020-07-21 02:22:03 +08:00
|
|
|
|
using PowerLauncher.ViewModel;
|
2020-07-03 04:48:41 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class Wox
|
|
|
|
|
{
|
|
|
|
|
// A Dummy class to test that OnPropertyChanged() is called while we set the variable
|
|
|
|
|
public class DummyTestClass : BaseModel
|
|
|
|
|
{
|
|
|
|
|
public bool isFunctionCalled = false;
|
|
|
|
|
private ICommand _item;
|
|
|
|
|
|
|
|
|
|
public ICommand Item
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this._item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != this._item)
|
|
|
|
|
{
|
|
|
|
|
this._item = value;
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Overriding the OnPropertyChanged() function to test if it is being called
|
|
|
|
|
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
|
|
{
|
|
|
|
|
isFunctionCalled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void AnyVariable_MustCallOnPropertyChanged_WhenSet()
|
|
|
|
|
{
|
|
|
|
|
// Arrange
|
|
|
|
|
DummyTestClass testClass = new DummyTestClass();
|
|
|
|
|
|
|
|
|
|
// Act
|
|
|
|
|
testClass.Item = new RelayCommand(null);
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.IsTrue(testClass.isFunctionCalled);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|