Skip to content

Commit

Permalink
UITest/InfoMan: extend ShowContactsTest (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbe2277 committed Sep 24, 2024
1 parent 996ff67 commit 3ab6b3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/Samples.UITest/InformationManager.Test/Tests/AddressBookTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContactListItem>().FirstnameLabel.Text, contactListView.ContactItems[0].FirstnameLabel.Text);
AssertContactItem(contactListView.ContactItems[0], contactView, "Jesper", "Aaberg", "[email protected]", "(111) 555-0100");
AssertContactItem(contactListView.ContactItems[^1], null, "Miles", "Reid", "[email protected]", "(444) 555-0123");

Assert.Equal(contactListView.ContactList.SelectedItem.As<ContactListItem>().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);
Expand All @@ -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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 3ab6b3c

Please sign in to comment.