Exemplo n.º 1
0
        public async Task OnGetProperty_WhenPropertyIsDependencyObject_GetVisualElement()
        {
            // Arrange
            await using TestRecorder recorder = new(App);

            await Window.SetXamlContent(@"
<StackPanel x:Name=""Panel"">
    <StackPanel.ContextMenu>
         <ContextMenu x:Name=""TestContextMenu""/>
    </StackPanel.ContextMenu>
</StackPanel>");

            IVisualElement <StackPanel> stackPanel = await Window.GetElement <StackPanel>("Panel");

            //Act
            IVisualElement <ContextMenu>?contextMenu = await stackPanel.GetContextMenu();

            //Assert
            Assert.IsNotNull(contextMenu);
            Assert.AreEqual("TestContextMenu", await contextMenu.GetName());
            recorder.Success();
        }