This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4de728e
commit 059f050
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
tests/Avalonia.Xaml.Interactions.UnitTests/Core/ChangePropertyActionTests.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,61 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Headless; | ||
using Avalonia.Headless.XUnit; | ||
using Avalonia.Input; | ||
using Avalonia.Xaml.Interactions.Core; | ||
using Avalonia.Xaml.Interactivity; | ||
using Xunit; | ||
|
||
namespace Avalonia.Xaml.Interactions.UnitTests.Core; | ||
|
||
public class ChangePropertyActionTests | ||
{ | ||
[AvaloniaFact] | ||
public void Should_Update_Text_Property_On_Click_Event() | ||
{ | ||
var textBox = new TextBox | ||
{ | ||
Text = "Initial Text" | ||
}; | ||
|
||
var button = new Button | ||
{ | ||
[Interaction.BehaviorsProperty] = new BehaviorCollection | ||
{ | ||
new EventTriggerBehavior | ||
{ | ||
EventName = "Click", | ||
Actions = | ||
{ | ||
new ChangePropertyAction | ||
{ | ||
TargetObject = textBox, | ||
PropertyName = "Text", | ||
Value = "Updated Text" | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
var window = new Window | ||
{ | ||
Content = new StackPanel | ||
{ | ||
Children = | ||
{ | ||
textBox, | ||
button | ||
} | ||
} | ||
}; | ||
|
||
window.Show(); | ||
|
||
// Click | ||
button.Focus(); | ||
window.KeyPress(Key.Enter, RawInputModifiers.None); | ||
|
||
Assert.Equal("Updated Text", textBox.Text); | ||
} | ||
} |