mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
* Added InvarientCulture info (CA1305: Specify IFormatProvider) * Removed underscore from method names (CA1707: Identifiers should not contain underscores) * Marked members as static (CA1822: Mark members as static) * Removed initialization for DummyTestClass::IsFunctionCalled (CA1805: Do not initialize unnecessarily) * Replaced Count with Any (CA1827: Do not use Count/LongCount when Any can be used) * Changed WoxTest::DummyTestClass to private (CA1034: Nested types should not be visible) * Suppressed warnings for uninstantiated internal classes used as TestFixtures (CA1812: Avoid uninstantiated internal classes) * Enabled FxCopAnalyzer for Wox.Test * Added suppression message for CA1812 in GlobalSuppressions.cs and removed inline supression messages (CA1812: Avoid uninstantiated internal classes) * Changed InvariantCulture to Ordinal where appropriate * Addressing comments: Updated justification for CA1812 in GlobalSuppressions.cs (Avoid uninstantiated internal classes)
61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows.Input;
|
|
using NUnit.Framework;
|
|
using PowerLauncher.ViewModel;
|
|
using Wox.Plugin;
|
|
|
|
namespace Wox.Test
|
|
{
|
|
[TestFixture]
|
|
public class WoxTest
|
|
{
|
|
// A Dummy class to test that OnPropertyChanged() is called while we set the variable
|
|
private class DummyTestClass : BaseModel
|
|
{
|
|
public bool IsFunctionCalled { get; set; }
|
|
|
|
private ICommand _item;
|
|
|
|
public ICommand Item
|
|
{
|
|
get
|
|
{
|
|
return _item;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (value != _item)
|
|
{
|
|
_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 AnyVariableMustCallOnPropertyChangedWhenSet()
|
|
{
|
|
// Arrange
|
|
DummyTestClass testClass = new DummyTestClass();
|
|
|
|
// Act
|
|
testClass.Item = new RelayCommand(null);
|
|
|
|
// Assert
|
|
Assert.IsTrue(testClass.IsFunctionCalled);
|
|
}
|
|
}
|
|
}
|