Пример #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);
     });
 }
Пример #2
0
 void Ex03()
 {
     When("the content of the to-do is set", () => Content.TodoContent.Value = TodoContent);
     When("the Tab key is pressed", () =>
     {
         UwpController.Using(Substitute.For <IKeyRoutedEventArgsResolver>(), typeof(KeyRoutedEventArgsWrapper))
         .Apply(resolver => resolver.Key(Arg.Any <KeyRoutedEventArgs>()).Returns(VirtualKey.Tab))
         .EventHandlersOf(Controller)
         .GetBy("TodoContentTextBox")
         .Raise(nameof(UIElement.KeyDown));
     });
     Then("a to-do item should not be added", () => Content.TodoItems.Count == 0);
 }