-
Notifications
You must be signed in to change notification settings - Fork 100
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 #309 from enisn/4.1-unit-tests
Update Unit Tests
- Loading branch information
Showing
5 changed files
with
78 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using InputKit.Maui.Test.TestClasses; | ||
using InputKit.Shared.Controls; | ||
using Shouldly; | ||
using System.Windows.Input; | ||
|
||
namespace InputKit.Maui.Test; | ||
public class AdvancedEntry_Tests | ||
{ | ||
public AdvancedEntry_Tests() | ||
{ | ||
ApplicationExtensions.CreateAndSetMockApplication(); | ||
} | ||
|
||
[Fact] | ||
public void Text_BindingForInitializtion_FromSource() | ||
{ | ||
var control = new AdvancedEntry(); | ||
var viewModel = new TestViewModel { Text = "Text Initial Value" }; | ||
control.BindingContext = viewModel; | ||
control.SetBinding(AdvancedEntry.TextProperty, new Binding(nameof(TestViewModel.Text))); | ||
|
||
// Assert | ||
control.Text.ShouldBe(viewModel.Text); | ||
} | ||
|
||
[Fact] | ||
public void Text_Binding_FromSource() | ||
{ | ||
var control = new AdvancedEntry(); | ||
var viewModel = new TestViewModel { Text = "Text Initial Value" }; | ||
control.BindingContext = viewModel; | ||
control.SetBinding(AdvancedEntry.TextProperty, new Binding(nameof(TestViewModel.Text))); | ||
|
||
// Act | ||
viewModel.Text = "Changed Value"; | ||
|
||
// Assert | ||
control.Text.ShouldBe(viewModel.Text); | ||
} | ||
|
||
public class TestViewModel : InputKitBindableObject | ||
{ | ||
private bool isChecked; | ||
private string text; | ||
|
||
public bool IsChecked { get => isChecked; set => SetProperty(ref isChecked, value); } | ||
|
||
public string Text { get => text; set => SetProperty(ref text, value); } | ||
|
||
public ICommand Command { get; set; } | ||
|
||
public object CommandParameter { get; set; } = "My Command Parameter 1"; | ||
} | ||
} |
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