Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DevFromDownUnder committed Mar 25, 2024
1 parent 1d78fce commit 9805ac1
Showing 1 changed file with 64 additions and 1 deletion.
65 changes: 64 additions & 1 deletion test/UraniumUI.Material.Tests/Controls/TextField_Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ public void Text_Binding_ToSource()
viewModel.Text.ShouldBe(control.Text);
}

[Fact]
public void TextProperty_Parent_ShouldTwoWayBind_Child()
{
var control = AnimationReadyHandler.Prepare(new TextField());

//Test Child->Parent
// Act
control.EntryView.Text = "Test 1";

// Assert
control.Text.ShouldBe(control.EntryView.Text);

//Test Parent->Child
// Act
control.Text = "Test 2";

// Assert
control.Text.ShouldBe(control.EntryView.Text);
}

[Fact]
public void SelectionLength_ShouldBeSent_ToViewModel()
{
Expand All @@ -86,6 +106,46 @@ public void SelectionLength_ShouldBeSent_ToViewModel()
viewModel.SelectionLength.ShouldBe(control.SelectionLength);
}

[Fact]
public void SelectionLengthProperty_Parent_ShouldTwoWayBind_Child ()
{
var control = AnimationReadyHandler.Prepare(new TextField());

//Test Child->Parent
// Act
control.EntryView.SelectionLength = 5;

// Assert
control.SelectionLength.ShouldBe(control.EntryView.SelectionLength);

//Test Parent->Child
// Act
control.SelectionLength = 10;

// Assert
control.SelectionLength.ShouldBe(control.EntryView.SelectionLength);
}

[Fact]
public void CursorPositionProperty_Parent_ShouldTwoWayBind_Child()
{
var control = AnimationReadyHandler.Prepare(new TextField());

//Test Child->Parent
// Act
control.EntryView.CursorPosition = 5;

// Assert
control.CursorPosition.ShouldBe(control.EntryView.CursorPosition);

//Test Parent->Child
// Act
control.CursorPosition = 10;

// Assert
control.CursorPosition.ShouldBe(control.EntryView.CursorPosition);
}

[Fact]
public void IsPassword_ShouldBeSet_FromViewModel()
{
Expand Down Expand Up @@ -186,8 +246,11 @@ public void ReturnCommandParameter_ShouldBeSet_FromViewModel()
// Act
control.SetBinding(TextField.ReturnCommandParameterProperty, new Binding(nameof(TestViewModel.CommandParameter)));

// Assert
// Assert child
control.EntryView.ReturnCommandParameter.ShouldBe(viewModel.CommandParameter);

// Assert parent
control.ReturnCommandParameter.ShouldBe(viewModel.CommandParameter);
}

[Fact]
Expand Down

0 comments on commit 9805ac1

Please sign in to comment.