From 3ab6b3c1b5c603d4765824f5ec0720ec750da8a2 Mon Sep 17 00:00:00 2001 From: jbe2277 Date: Tue, 24 Sep 2024 21:53:25 +0200 Subject: [PATCH] UITest/InfoMan: extend ShowContactsTest (part 2) --- .../Tests/AddressBookTest.cs | 20 +++++++++---------- .../Views/ContactListView.cs | 7 +++---- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Samples.UITest/InformationManager.Test/Tests/AddressBookTest.cs b/src/Samples.UITest/InformationManager.Test/Tests/AddressBookTest.cs index 7052237e..d2e22abb 100644 --- a/src/Samples.UITest/InformationManager.Test/Tests/AddressBookTest.cs +++ b/src/Samples.UITest/InformationManager.Test/Tests/AddressBookTest.cs @@ -19,16 +19,17 @@ public void ShowContactsTest() => Run(() => var count = contactListView.ContactItems.Count; Assert.Equal(5, count); Log.WriteLine($"List of Contacts ({count})"); - for (int i = 0; i < count; i++) - { - var (f, l, e, p) = contactListView.ContactItems[i]; - Log.WriteLine($"{i:00}: {f} {l}; {e} {p}"); - } + for (int i = 0; i < count; i++) Log.WriteLine($"{i:00}: {contactListView.ContactItems[i].ToTuple()}"); - Assert.Equal(contactListView.ContactList.SelectedItem.As().FirstnameLabel.Text, contactListView.ContactItems[0].FirstnameLabel.Text); AssertContactItem(contactListView.ContactItems[0], contactView, "Jesper", "Aaberg", "jesper.aaberg@example.com", "(111) 555-0100"); AssertContactItem(contactListView.ContactItems[^1], null, "Miles", "Reid", "miles.reid@adventure-works.com", "(444) 555-0123"); - + Assert.Equal(contactListView.ContactList.SelectedItem.As().ToTuple(), contactListView.ContactItems[0].ToTuple()); + Assert.Equal("Main St. 4567", contactView.StreetBox.Text); + Assert.Equal("Buffalo", contactView.CityBox.Text); + Assert.Equal("New York", contactView.StateBox.Text); + Assert.Equal("98052", contactView.PostalCodeBox.Text); + Assert.Equal("United States", contactView.CountryBox.Text); + Assert.Equal("Search", contactListView.SearchBox.SearchHintLabel.Text); contactListView.SearchBox.SearchTextBox.Text = "!"; Assert.Empty(contactListView.ContactItems); @@ -44,11 +45,10 @@ public void ShowContactsTest() => Run(() => private static void AssertContactItem(ContactListItem contactItem, ContactView? contactView, string firstName, string lastName, string email, string phone) { - var (f, l, e, p) = contactItem; - Assert.Equal((firstName, lastName, email, phone), (f, l, e, p)); + Assert.Equal((firstName, lastName, email, phone), contactItem.ToTuple()); if (contactView is not null) { - Assert.Equal((f, l, e, p), (contactView.FirstnameBox.Text, contactView.LastnameBox.Text, contactView.EmailBox.Text, contactView.PhoneBox.Text)); + Assert.Equal(contactItem.ToTuple(), (contactView.FirstnameBox.Text, contactView.LastnameBox.Text, contactView.EmailBox.Text, contactView.PhoneBox.Text)); } } } diff --git a/src/Samples.UITest/InformationManager.Test/Views/ContactListView.cs b/src/Samples.UITest/InformationManager.Test/Views/ContactListView.cs index c4bfaeea..2ecefce1 100644 --- a/src/Samples.UITest/InformationManager.Test/Views/ContactListView.cs +++ b/src/Samples.UITest/InformationManager.Test/Views/ContactListView.cs @@ -23,8 +23,7 @@ public class ContactListItem(FrameworkAutomationElementBase element) : ListBoxIt public Label PhoneLabel => this.Find("PhoneLabel").AsLabel(); - public void Deconstruct(out string firstname, out string lastname, out string email, out string phone) - { - (firstname, lastname, email, phone) = (FirstnameLabel.Text, LastnameLabel.Text, EmailLabel.Text, PhoneLabel.Text); - } + public void Deconstruct(out string firstname, out string lastname, out string email, out string phone) => (firstname, lastname, email, phone) = ToTuple(); + + public (string firstname, string lastname, string email, string phone) ToTuple() => (FirstnameLabel.Text, LastnameLabel.Text, EmailLabel.Text, PhoneLabel.Text); } \ No newline at end of file