void Ex02() { var loadedEventHandled = false; TestUwpControllers.TestUwpControllerAsync controller = null; Given("a controller", () => controller = new TestUwpControllers.TestUwpControllerAsync { LoadedAssertionHandler = () => loadedEventHandled = true }); When("the Loaded event is raised asynchronously using the EventHandlerBase", async() => await UwpController.EventHandlersOf(controller) .GetBy("Element") .RaiseAsync("Loaded") ); Then("the Loaded event should be handled", () => loadedEventHandled); }
void Ex05() { var keyDownHandler = Substitute.For <Action <VirtualKey> >(); TestUwpControllers.TestUwpControllerAsync controller = null; Given("a controller", () => controller = new TestUwpControllers.TestUwpControllerAsync { KeyDownAssertionHandler = keyDownHandler }); When("the KeyDown event is raised asynchronously using the EventHandlerBase", async() => await UwpController.Using(Substitute.For <IKeyRoutedEventArgsResolver>(), typeof(KeyRoutedEventArgsWrapper)) .Apply(resolver => resolver.Key(Arg.Any <KeyRoutedEventArgs>()).Returns(VirtualKey.Enter)) .EventHandlersOf(controller) .GetBy("Element") .RaiseAsync("KeyDown") ); Then("the KeyDown event should be handled", () => keyDownHandler.Received(1).Invoke(VirtualKey.Enter)); }
void Ex09() { var pointerPressedHandler = Substitute.For <Action <PointerDeviceType> >(); TestUwpControllers.TestUwpControllerAsync controller = null; Given("a controller", () => controller = new TestUwpControllers.TestUwpControllerAsync { PointerPressedHandler = pointerPressedHandler }); When("the PointerPressed event is raised asynchronously using the EventHandlerBase", async() => await UwpController.Using(Substitute.For <IPointerRoutedEventArgsResolver>(), typeof(PointerRoutedEventArgsWrapper)) .Apply(resolver => resolver.Pointer(Arg.Any <PointerRoutedEventArgs>()).Returns((Pointer)null)) .Using(Substitute.For <IPointerResolver>(), typeof(PointerWrapper)) .Apply(resolver => resolver.PointerDeviceType(Arg.Any <Pointer>()).Returns(PointerDeviceType.Mouse)) .EventHandlersOf(controller) .GetBy("Element") .RaiseAsync("PointerPressed") ); Then("the PointerPressed event should be handled", () => pointerPressedHandler.Received(1).Invoke(PointerDeviceType.Mouse)); }