1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+ // See the LICENSE file in the project root for more information.
4+
5+ using System . Collections . Generic ;
6+ using System . Collections . ObjectModel ;
7+ using System . Diagnostics ;
8+ using System . Linq ;
9+ using Microsoft . Toolkit . Uwp . UI . Controls ;
10+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
11+ using Microsoft . VisualStudio . TestTools . UnitTesting . AppContainer ;
12+ using Windows . UI . Xaml . Automation . Peers ;
13+ using Microsoft . Toolkit . Uwp . UI . Automation . Peers ;
14+
15+ namespace UnitTests . UWP . UI . Controls
16+ {
17+ [ TestClass ]
18+ [ TestCategory ( "Test_Carousel" ) ]
19+ public class Test_Carousel
20+ {
21+ [ UITestMethod ]
22+ public void ShouldConfigureCarouselAutomationPeer ( )
23+ {
24+ var items = new ObservableCollection < PhotoDataItem > { new PhotoDataItem { Title = "Hello" } , new PhotoDataItem { Title = "World" } } ;
25+ var carousel = new Carousel { ItemsSource = items } ;
26+
27+ var carouselPeer = FrameworkElementAutomationPeer . CreatePeerForElement ( carousel ) as CarouselAutomationPeer ;
28+
29+ Assert . IsNotNull ( carouselPeer , "Verify that the AutomationPeer is CarouselAutomationPeer." ) ;
30+ Assert . IsFalse ( carouselPeer . CanSelectMultiple , "Verify that CarouselAutomationPeer.CanSelectMultiple is false." ) ;
31+ Assert . IsFalse ( carouselPeer . IsSelectionRequired , "Verify that CarouselAutomationPeer.IsSelectionRequired is false." ) ;
32+
33+ Assert . IsTrue ( carouselPeer . GetName ( ) . Contains ( nameof ( Carousel ) ) , "Verify that the UIA name contains the class name of the Carousel." ) ;
34+ carousel . Name = "TextItems" ;
35+ Assert . IsTrue ( carouselPeer . GetName ( ) . Contains ( carousel . Name ) , "Verify that the UIA name contains the given name of the Carousel." ) ;
36+ }
37+
38+ public class PhotoDataItem
39+ {
40+ public string Title { get ; set ; }
41+
42+ public string Category { get ; set ; }
43+
44+ public string Thumbnail { get ; set ; }
45+
46+ public override string ToString ( )
47+ {
48+ return Title ;
49+ }
50+ }
51+ }
52+ }
0 commit comments