feat: add fail test.
This commit is contained in:
@@ -3,6 +3,7 @@ using Avalonia.Headless;
|
|||||||
using Avalonia.Headless.XUnit;
|
using Avalonia.Headless.XUnit;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Ursa.Controls;
|
using Ursa.Controls;
|
||||||
|
|
||||||
namespace HeadlessTest.Ursa.Controls.PinCodeTests;
|
namespace HeadlessTest.Ursa.Controls.PinCodeTests;
|
||||||
@@ -13,9 +14,11 @@ public class PasteTest
|
|||||||
public async void Paste_Should_Insert_Text()
|
public async void Paste_Should_Insert_Text()
|
||||||
{
|
{
|
||||||
var window = new Window();
|
var window = new Window();
|
||||||
|
bool commandInvoked = false;
|
||||||
var pinCode = new PinCode()
|
var pinCode = new PinCode()
|
||||||
{
|
{
|
||||||
Count = 4,
|
Count = 4,
|
||||||
|
CompleteCommand = new RelayCommand(() => commandInvoked = true),
|
||||||
};
|
};
|
||||||
window.Content = pinCode;
|
window.Content = pinCode;
|
||||||
window.Show();
|
window.Show();
|
||||||
@@ -27,15 +30,18 @@ public class PasteTest
|
|||||||
// add await for clipboard processing.
|
// add await for clipboard processing.
|
||||||
await Task.Delay(1);
|
await Task.Delay(1);
|
||||||
Assert.Equal("abcd", string.Join("", pinCode.Digits));
|
Assert.Equal("abcd", string.Join("", pinCode.Digits));
|
||||||
|
Assert.True(commandInvoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public async void Paste_Should_Insert_Text_When_Text_Is_Shorter()
|
public async void Paste_Should_Insert_Text_When_Text_Is_Shorter()
|
||||||
{
|
{
|
||||||
var window = new Window();
|
var window = new Window();
|
||||||
|
bool commandInvoked = false;
|
||||||
var pinCode = new PinCode()
|
var pinCode = new PinCode()
|
||||||
{
|
{
|
||||||
Count = 4,
|
Count = 4,
|
||||||
|
CompleteCommand = new RelayCommand(() => commandInvoked = true),
|
||||||
};
|
};
|
||||||
window.Content = pinCode;
|
window.Content = pinCode;
|
||||||
window.Show();
|
window.Show();
|
||||||
@@ -46,15 +52,18 @@ public class PasteTest
|
|||||||
window.KeyPressQwerty(PhysicalKey.V, RawInputModifiers.Control);
|
window.KeyPressQwerty(PhysicalKey.V, RawInputModifiers.Control);
|
||||||
await Task.Delay(1);
|
await Task.Delay(1);
|
||||||
Assert.Equal("abc", string.Join("", pinCode.Digits));
|
Assert.Equal("abc", string.Join("", pinCode.Digits));
|
||||||
|
Assert.False(commandInvoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public async void Paste_Should_Insert_Text_When_Text_Is_Longer()
|
public async void Paste_Should_Insert_Text_When_Text_Is_Longer()
|
||||||
{
|
{
|
||||||
var window = new Window();
|
var window = new Window();
|
||||||
|
bool commandInvoked = false;
|
||||||
var pinCode = new PinCode()
|
var pinCode = new PinCode()
|
||||||
{
|
{
|
||||||
Count = 4,
|
Count = 4,
|
||||||
|
CompleteCommand = new RelayCommand(() => commandInvoked = true),
|
||||||
};
|
};
|
||||||
window.Content = pinCode;
|
window.Content = pinCode;
|
||||||
window.Show();
|
window.Show();
|
||||||
@@ -65,16 +74,19 @@ public class PasteTest
|
|||||||
window.KeyPressQwerty(PhysicalKey.V, RawInputModifiers.Control);
|
window.KeyPressQwerty(PhysicalKey.V, RawInputModifiers.Control);
|
||||||
await Task.Delay(1);
|
await Task.Delay(1);
|
||||||
Assert.Equal("abcd", string.Join("", pinCode.Digits));
|
Assert.Equal("abcd", string.Join("", pinCode.Digits));
|
||||||
|
Assert.True(commandInvoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public async void Paste_Should_Not_Insert_Text_When_Text_Is_In_Invalid_Mode()
|
public async void Paste_Should_Not_Insert_Text_When_Text_Is_In_Invalid_Mode()
|
||||||
{
|
{
|
||||||
var window = new Window();
|
var window = new Window();
|
||||||
|
var commandInvoked = false;
|
||||||
var pinCode = new PinCode()
|
var pinCode = new PinCode()
|
||||||
{
|
{
|
||||||
Count = 4,
|
Count = 4,
|
||||||
Mode = PinCodeMode.Digit,
|
Mode = PinCodeMode.Digit,
|
||||||
|
CompleteCommand = new RelayCommand(() => commandInvoked = true),
|
||||||
};
|
};
|
||||||
window.Content = pinCode;
|
window.Content = pinCode;
|
||||||
window.Show();
|
window.Show();
|
||||||
@@ -85,5 +97,6 @@ public class PasteTest
|
|||||||
window.KeyPressQwerty(PhysicalKey.V, RawInputModifiers.Control);
|
window.KeyPressQwerty(PhysicalKey.V, RawInputModifiers.Control);
|
||||||
await Task.Delay(1);
|
await Task.Delay(1);
|
||||||
Assert.Equal("", string.Join("", pinCode.Digits));
|
Assert.Equal("", string.Join("", pinCode.Digits));
|
||||||
|
Assert.False(commandInvoked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user