public void CanUnregisterEventRoute() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); pkg.RegisterEventRoute(route); pkg.UnregisterEventRoute(route); Assert.IsTrue(!pkg.RegisteredEventRoutes.Any()); }
public void DuplicateEventRoutesDisalllowed() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); pkg.RegisterEventRoute(route); pkg.RegisterEventRoute(route); Assert.AreEqual(pkg.RegisteredEventRoutes.Count(), 1); pkg.UnregisterEventRoute(route); }
public void CanCancelEventRouteUnregistration() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); bool shouldCancel = true; pkg.EventRoutePreUnregister += (s, e) => { e.Cancel = shouldCancel; shouldCancel = false; }; pkg.RegisterEventRoute(route); pkg.UnregisterEventRoute(route); Assert.IsTrue(pkg.RegisteredEventRoutes.Any()); pkg.UnregisterEventRoute(route); }
public void CanUnregisterAllRoutes() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToMethodRoute eRoute = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); PropertyToMethodRoute pRoute = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x)); pkg.RegisterEventRoute(eRoute); pkg.RegisterPropertyRoute(pRoute); pkg.UnregisterAll(); Assert.IsTrue(!pkg.RegisteredEventRoutes.Any() & !pkg.RegisteredPropertyRoutes.Any()); }
public void CanAttachToEventRouteUnregistered() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); bool caught = false; pkg.EventRouteUnregistered += (s, e) => { caught = e.EventRoute == route; }; pkg.RegisterEventRoute(route); pkg.UnregisterEventRoute(route); Assert.IsTrue(caught); }
public void ComponentsRegistration() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); pkg.RegisterEventRoute(route); Assert.AreEqual <int>(2, pkg.Components.Count()); pkg.UnregisterEventRoute(route); Assert.AreEqual <int>(0, pkg.Components.Count()); }
public void CanRegisterEventArgsRoute() { OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); TestEventArgs e = new TestEventArgs("RouteOut", 100); EventToMethodRoute route = EventToMethodRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, (x) => inComponent.TestEventArgsActionIn(x)); route.RegisterRoute(); if (!route.IsRegistered) { Assert.Fail("Route not registered."); } outComponent.RaiseTestEventOut(e); route.UnregisterRoute(); Assert.AreEqual(inComponent.IntInProperty, e.EventInteger); }