Example #1
0
 async Task Ex05()
 {
     await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         UwpController.SetElement(new TextBox {
             Name = "TodoContentTextBox"
         }, Controller, true);
         When("the element is double tapped", () =>
              UwpController.EventHandlersOf(Controller)
              .GetBy("TodoItemContainer")
              .Raise(nameof(UIElement.DoubleTapped))
              );
         When("the content is modified", () => TodoItem.EditContent.Value = ModifiedContent);
         When("the Esc key is pressed", () =>
         {
             UwpController.Using(Substitute.For <IKeyRoutedEventArgsResolver>(), typeof(KeyRoutedEventArgsWrapper))
             .Apply(resolver => resolver.Key(Arg.Any <KeyRoutedEventArgs>()).Returns(VirtualKey.Escape))
             .EventHandlersOf(Controller)
             .GetBy("TodoContentTextBox")
             .Raise(nameof(UIElement.KeyDown));
         });
         Then("the to-do item should not be editing", () => !TodoItem.Editing.Value);
         Then("the content of the to-do item should be the initial content", () => TodoItem.Content.Value == InitialContent);
     });
 }
Example #2
0
 async Task Ex02()
 {
     await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         UwpController.SetElement(new TextBox {
             Name = "TodoContentTextBox"
         }, Controller, true);
         When("the element is double tapped", () =>
              UwpController.EventHandlersOf(Controller)
              .GetBy("TodoItemContainer")
              .Raise(nameof(UIElement.DoubleTapped))
              );
         Then("the to-do item should be editing", () => TodoItem.Editing.Value);
         Then("the edit content of the to-do item should be the initial content", () => TodoItem.EditContent.Value == InitialContent);
     });
 }
 async Task Ex01()
 {
     await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var allCompletedCheckBox = new CheckBox {
             Name = "AllCompletedCheckBox"
         };
         UwpController.SetElement(allCompletedCheckBox, Controller, true);
         When("AllCompleted of the content is set to true", () => Content.AllCompleted.Value = true);
         When("IsChecked of the AllCompletedCheckBox is set to true", () => allCompletedCheckBox.IsChecked = true);
         When("the element is loaded", () =>
              UwpController.EventHandlersOf(Controller)
              .GetBy(null)
              .Raise(nameof(FrameworkElement.Loaded))
              );
         When("the AllCompleted of the content is set to null", () => Content.AllCompleted.Value = null);
         Then("the IsChecked of the AllCompletedCheckBox should be null", () => allCompletedCheckBox.IsChecked = null);
     });
 }
Example #4
0
        async Task Ex01()
        {
            await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Grid element = null;
                Given("an element with a visual state", () =>
                {
                    element = new Grid {
                        Name = "TodoItemContainer"
                    };
                    VisualStateManager.GetVisualStateGroups(element).Add(XamlReader.Load(@"
<VisualStateGroup xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                  xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
    <VisualState x:Name=""Normal"" />
    <VisualState x:Name=""PointerOver"" />
</VisualStateGroup>
") as VisualStateGroup);
                });
                UwpController.SetElement(new UserControl {
                    Name = "Root", Content = element
                }, Controller);
                When("a pointer enters into the element", () =>
                     UwpController.EventHandlersOf(Controller)
                     .GetBy(element.Name)
                     .From(element)
                     .Raise(nameof(UIElement.PointerEntered))
                     );
                Then("the current state of the element should be 'PointerOver'", () => VisualStateManager.GetVisualStateGroups(element)[0].CurrentState.Name == "PointerOver");
                When("a pointer exits the element", () =>
                     UwpController.EventHandlersOf(Controller)
                     .GetBy(element.Name)
                     .From(element)
                     .Raise(nameof(UIElement.PointerExited))
                     );
                Then("the current state of the element should be 'Normal'", () => VisualStateManager.GetVisualStateGroups(element)[0].CurrentState.Name == "Normal");
            });
        }