Пример #1
0
 async Task Ex03(TestUwpControllers.ITestUwpController controller)
 {
     await RunAsync(() =>
     {
         Given("a data context", () => DataContext = new object());
         When("the data context is set to the controller using the UwpController", () => UwpController.SetDataContext(DataContext, controller));
         Then("the data context should be set to the controller", () => controller.DataContext == DataContext);
     });
 }
Пример #2
0
 async Task Ex02(TestUwpControllers.ITestUwpController controller)
 {
     await RunAsync(() =>
     {
         Given("a child element", () => ChildElement = new TestElement {
             Name = "childElement"
         });
         Given("an element", () => Element = new TestElement {
             Name = "element"
         });
         When("the child element is set to the controller using the UwpController", () => UwpController.SetElement(ChildElement, controller, true));
         When("the element is set to the controller using the UwpController", () => UwpController.SetElement(Element, controller, true));
         Then("the element should be set to the controller", () => controller.Element == Element);
         Then("the child element should be set to the controller", () => controller.ChildElement == ChildElement);
     });
 }
Пример #3
0
        async Task Ex01(TestUwpControllers.ITestUwpController controller)
        {
            await RunAsync(() =>
            {
                Given("a data context", () => DataContext   = new object());
                Given("a child element", () => ChildElement = new TestElement {
                    Name = "childElement"
                });
                Given("an element that has the child element", () => Element = new TestElement {
                    Name = "element", Content = ChildElement, DataContext = DataContext
                });

                When("the controller is added", () => UwpController.GetControllers(Element).Add(controller));
                When("the controller is attached to the element", () => UwpController.GetControllers(Element).AttachTo(Element));

                Then("the data context of the controller should be set", () => controller.DataContext == DataContext);
                Then("the element of the controller should be null", () => controller.Element == null);
                Then("the child element of the controller should be null", () => controller.ChildElement == null);
            });

            EventHandled = false;
            When("the element is set to the content of the window", async() => await SetWindowContent(Element));

            Then("the data context of the controller should be set", () => controller.DataContext == DataContext);
            Then("the element of the controller should be set", () => controller.Element == Element);
            Then("the child element of the controller should be set", () => controller.ChildElement == ChildElement);
            Then("the event should be handled", () => EventHandled);

            await RunAsync(() =>
            {
                EventHandled = false;
                When("the Changed event of the child element is raised", () => ChildElement.RaiseChanged());
                Then("the Changed event should be handled", () => EventHandled);

                EventHandled = false;
                When("the data context of the child element should be set", () => ChildElement.DataContext = new object());
                Then("the DataContextChanged event should be handled", () => EventHandled);
            });
        }