diff --git a/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs b/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs index c06c910b..2e7f89ed 100644 --- a/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs +++ b/src/Samples.UITest/BookLibrary.Test/Tests/BookLibraryTest.cs @@ -32,7 +32,7 @@ public void AboutTest() } [Fact] - public void SearchBookListTest() + public void SearchBookListAndChangeEntriesTest() { Launch(); var window = GetShellWindow(); @@ -59,6 +59,26 @@ public void SearchBookListTest() bookView.TitleTextBox.Text = "Test Title"; Assert.Equal("Test Title", bookRow2.TitleCell.Name); + bookView.AuthorTextBox.Text = "TAuthor"; + Assert.Equal("TAuthor", bookRow2.AuthorCell.Name); + bookView.PublishDatePicker.SelectedDate = new DateTime(2024, 3, 2); + Assert.Equal("2/3/2024", bookRow2.PublishDateCell.Name); + Assert.Equal(["Undefined", "English", "German", "French", "Spanish", "Chinese", "Japanese"], bookView.LanguageComboBox.Items.Select(x => x.Name)); + bookView.LanguageComboBox.Select(2); + bookView.LanguageComboBox.Click(); // To close the combo box popup + Assert.Equal("German", bookView.LanguageComboBox.SelectedItem.Text); + + bookView.LendToButton.Click(); + var lendToWindow = window.FirstModalWindow().As(); + Assert.True(lendToWindow.WasReturnedRadioButton.IsChecked); + Assert.False(lendToWindow.LendToRadioButton.IsChecked); + Assert.False(lendToWindow.PersonListBox.IsEnabled); + lendToWindow.LendToRadioButton.Click(); + Assert.True(lendToWindow.PersonListBox.IsEnabled); + Assert.Equal(["Ginny", "Hermione", "Harry", "Ron"], lendToWindow.PersonListBox.Items.Select(x => x.Text)); + lendToWindow.PersonListBox.Items[2].Select(); + lendToWindow.OkButton.Click(); + AssertEqual("Harry Potter", bookRow2.LendToCell.LendToLabel.Name, bookView.LendToTextBox.Text); window.Close(); var messageBox = window.FirstModalWindow().As(); // MessageBox that asks user to save the changes diff --git a/src/Samples.UITest/BookLibrary.Test/Views/LendToWindow.cs b/src/Samples.UITest/BookLibrary.Test/Views/LendToWindow.cs new file mode 100644 index 00000000..48fd4e4a --- /dev/null +++ b/src/Samples.UITest/BookLibrary.Test/Views/LendToWindow.cs @@ -0,0 +1,17 @@ +using FlaUI.Core; +using FlaUI.Core.AutomationElements; + +namespace UITest.BookLibrary.Views; + +public class LendToWindow(FrameworkAutomationElementBase element) : Window(element) +{ + public RadioButton WasReturnedRadioButton => this.Find("WasReturnedRadioButton").AsRadioButton(); + + public RadioButton LendToRadioButton => this.Find("LendToRadioButton").AsRadioButton(); + + public ListBox PersonListBox => this.Find("PersonListBox").AsListBox(); + + public Button OkButton => this.Find("OkButton").AsButton(); + + public Button CancelButton => this.Find("CancelButton").AsButton(); +} diff --git a/src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Presentation/Views/LendToWindow.xaml b/src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Presentation/Views/LendToWindow.xaml index 89b1b302..64ede51f 100644 --- a/src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Presentation/Views/LendToWindow.xaml +++ b/src/System.Waf/Samples/BookLibrary/BookLibrary.Library.Presentation/Views/LendToWindow.xaml @@ -11,19 +11,21 @@