Aug 22, 2011 at 4:09 PM
Edited Aug 22, 2011 at 6:54 PM
I am attempting to count the number of items in a Listbox to verify that objects are properly added when a button is pressed. I've discovered when playing around with the code that it does not count duplicate objects using the White.Core.UIItems.ListBoxItems.ListBox.Items.Count
method. Here is an example below:
In xaml I have a System.Windows.Controls.Listbox object. When I hit a click a button I add 3 objects to the listbox:
I then in a White Unit test run the following:
I get a successful result, as it detects 3 items. The unit test then clicks the button again, and it adds runs the code again adding the items. On the screen I can see 6 items in the listbox as follows:
In debug mode, viewing the listbox it contains 6 objects, the objects I'm seeing on the screen. I then do another assert:
This time the unit test fails with the number of items expected is 6, but actual is 3.
In running the same test with the 2nd button press changed to different code as follows:
Running Assert.AreEqual(6, listbox.Items.Count); Finds 5 values now instead of 3. Two of the objects are now different, while the myString object is still the same. I've also done this with combinations of other objects.
Has anyone else ran into this issue? I've reported it now as an issue: http://white.codeplex.com/workitem/11208