void Ex02() { Extension = new TestExtension(); Given("a controller", () => Controller = new TestUwpControllers.TestUwpController()); When("an extension is added", () => UwpController.AddExtension(Extension)); Then("the container of the extension should be retrieved", () => UwpController.Retrieve <TestExtension, object>(Controller) == TestExtension.TestExtensionContainer); }
async Task Ex01() { Extension = Substitute.For <IUwpControllerExtension>(); await RunAsync(() => { Given("an element that contains a data context", () => Element = new TestElement { DataContext = DataContext }); When("the UwpController is enabled for the element", () => { UwpController.SetIsEnabled(Element, true); Controller = UwpController.GetControllers(Element)[0] as TestUwpControllers.TestUwpController; }); When("the extension is added", () => UwpController.AddExtension(Extension)); }); When("the element is set for the content of the window", async() => await SetWindowContent(Element)); Then("the extension should be attached", () => Extension.Received().Attach(Controller, Element)); When("the content of the window is cleared in order to unload the element", async() => await ClearWindowContent()); Then("the extension should be detached", () => Extension.Received().Detach(Controller, Element)); }