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); }); }
void Ex01() { When("the ApplicationHost is loaded", () => UwpController.EventHandlersOf(Controller) .GetBy(null) .Raise(nameof(FrameworkElement.Loaded)) ); Then("the content should be navigated to the LoginContent", () => { Navigator.Received(1).NavigateTo(Arg.Any <LoginContent>()); }); }
void Ex01() { When("to log out", () => UwpController.EventHandlersOf(Controller) .GetBy("LogoutButton") .Raise(nameof(ButtonBase.Click)) ); Then("the content should be navigated to the LoginContent", () => { Navigator.Received(1).NavigateTo(Arg.Any <LoginContent>()); }); }
async Task Ex06() { await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { When("the delete button is clicked", () => UwpController.EventHandlersOf(Controller) .GetBy("DeleteButton") .Raise(nameof(ButtonBase.Click)) ); Then("it should be requested to remove the to-do item", () => RemoveRequested); }); }
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); }
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); }); }
async Task Ex02() { await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { When("the unauthenticated user information is set", () => { UserAuthentication.Authenticate(LoginContent).Returns(UserAuthenticationResult.Failure); LoginContent.UserId.Value = "user"; LoginContent.Password.Value = "password"; }); When("to click the Login button", () => UwpController.EventHandlersOf(LoginController) .GetBy("LoginButton") .Raise(nameof(ButtonBase.Click)) ); Then("the content should not be navigated to any contents", () => { Navigator.DidNotReceive().NavigateTo(Arg.Any <object>()); }); Then("the error message should be set", () => LoginContent.Message.Value == Resources.LoginFailure); }); }
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"); }); }
async Task Ex01() { await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { When("the authenticated user information is set", () => { UserAuthentication.Authenticate(LoginContent).Returns(UserAuthenticationResult.Success); LoginContent.UserId.Value = "user"; LoginContent.Password.Value = "password"; }); When("the message is set", () => LoginContent.Message.Value = "message"); When("to click the Login button", () => UwpController.EventHandlersOf(LoginController) .GetBy("LoginButton") .Raise(nameof(ButtonBase.Click)) ); Then("the content should be navigated to the HomeContent", () => { Navigator.Received(1).NavigateTo(Arg.Is <HomeContent>(content => content.Id == LoginContent.UserId.Value)); }); Then("the message should be empty", () => LoginContent.Message.Value == string.Empty); }); }
public LoginControllerSpec() { LoginController = new LoginController(Navigator, UserAuthentication); UwpController.SetDataContext(LoginContent, LoginController); }
public ApplicationHostControllerSpec() { Controller = new ApplicationHostController(Navigator); UwpController.SetDataContext(Host, Controller); }
public TodoItemControllerSpec() { TodoItem = new TodoItem(InitialContent); TodoItem.RemoveRequested += (s, e) => RemoveRequested = true; UwpController.SetDataContext(TodoItem, Controller); }
public MainContentControllerSpec() { UwpController.SetDataContext(Content, Controller); }