public void CanSetComponentName() { string name = "Component"; InComponent component = new InComponent(name); Assert.IsTrue(string.Compare(name, component.Name, false) == 0); }
public void ComponentHasUniqueId() { InComponent component1 = new InComponent("Component1"); InComponent component2 = new InComponent("Component2"); Assert.IsTrue(component1.Id != component2.Id); }
public void CanRegisterPropertyToPropertyRoute() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); PropertyToPropertyRoute route = PropertyToPropertyRoute.Create(outComponent, x => outComponent.StringOutProperty, inComponent, x => inComponent.StringInProperty); pkg.RegisterPropertyRoute(route); Assert.IsTrue(pkg.RegisteredPropertyRoutes.Any()); pkg.UnregisterPropertyRoute(route); }
public void CanRegisterEventToPropertyRoute() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); EventToPropertyRoute route = EventToPropertyRoute.Create <TestEventArgs>(outComponent, "TestEventOut", inComponent, x => inComponent.TestEventArgsInProperty); pkg.RegisterEventRoute(route); Assert.IsTrue(pkg.RegisteredEventRoutes.Any()); pkg.UnregisterEventRoute(route); }
public void CanUnregisterPropertyRoute() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); PropertyToMethodRoute route = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x)); pkg.RegisterPropertyRoute(route); pkg.UnregisterPropertyRoute(route); Assert.IsTrue(!pkg.RegisteredPropertyRoutes.Any()); }
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 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 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 DuplicatePropertyRoutesDisalllowed() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); PropertyToMethodRoute route = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x)); pkg.RegisterPropertyRoute(route); pkg.RegisterPropertyRoute(route); Assert.AreEqual(pkg.RegisteredPropertyRoutes.Count(), 1); pkg.UnregisterPropertyRoute(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 CanCancelEventRouteRegistration() { 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.EventRoutePreRegister += (s, e) => { e.Cancel = true; }; pkg.RegisterEventRoute(route); Assert.IsTrue(!pkg.RegisteredEventRoutes.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 CanAttachToPropertyRouteUnregistered() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); PropertyToMethodRoute route = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x)); bool caught = false; pkg.PropertyRouteUnregistered += (s, e) => { caught = e.PropertyRoute == route; }; pkg.RegisterPropertyRoute(route); pkg.UnregisterPropertyRoute(route); Assert.IsTrue(caught); }
public void CanRegisterPropertyRoute() { OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); PropertyToPropertyRoute route = PropertyToPropertyRoute.Create(outComponent, x => outComponent.IntOutProperty, inComponent, x => inComponent.IntInProperty); route.RegisterRoute(); if (!route.IsRegistered) { Assert.Fail("Route not registered."); } outComponent.IntOutProperty = 100; route.UnregisterRoute(); Assert.AreEqual(outComponent.IntOutProperty, inComponent.IntInProperty); }
public void CanCancelPropertyRouteUnregistration() { Package pkg = new Package(); OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); PropertyToMethodRoute route = PropertyToMethodRoute.Create <string>(outComponent, x => outComponent.StringOutProperty, inComponent, (x) => inComponent.StringActionIn(x)); bool shouldCancel = true; pkg.PropertyRoutePreUnregister += (s, e) => { e.Cancel = shouldCancel; shouldCancel = false; }; pkg.RegisterPropertyRoute(route); pkg.UnregisterPropertyRoute(route); Assert.IsTrue(pkg.RegisteredPropertyRoutes.Any()); pkg.UnregisterPropertyRoute(route); }
public void CanRegisterPropertyRouteWithReferenceConverter() { OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); IntToStringRouteConverter converter = new IntToStringRouteConverter(); PropertyToPropertyRoute route = PropertyToPropertyRoute.Create <string>(outComponent, "IntOutProperty", inComponent, x => inComponent.StringInProperty, converter); route.RegisterRoute(); if (!route.IsRegistered) { Assert.Fail("Route not registered."); } outComponent.IntOutProperty = 100; route.UnregisterRoute(); Assert.IsTrue(string.Compare(outComponent.IntOutProperty.ToString(), inComponent.StringInProperty, false) == 0); }
public void CanRegisterPropertyRouteWithValueConverter() { OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); StringToIntRouteConverter converter = new StringToIntRouteConverter(); PropertyToPropertyRoute route = PropertyToPropertyRoute.Create <int>(outComponent, "StringOutProperty", inComponent, x => inComponent.IntInProperty, converter); route.RegisterRoute(); if (!route.IsRegistered) { Assert.Fail("Route not registered."); } outComponent.StringOutProperty = "100"; route.UnregisterRoute(); Assert.AreEqual(100, inComponent.IntInProperty); }
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); }
public void CanRegisterEventArgsRouteWithValueConverter() { OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); TestEventArgs e = new TestEventArgs("RouteOut", 100); TestEventArgsToIntRouteConverter converter = new TestEventArgsToIntRouteConverter(); EventToPropertyRoute route = EventToPropertyRoute.Create(outComponent, "TestEventOut", inComponent, x => inComponent.IntInProperty, converter); route.RegisterRoute(); if (!route.IsRegistered) { Assert.Fail("Route not registered."); } outComponent.RaiseTestEventOut(e); route.UnregisterRoute(); Assert.AreEqual(inComponent.IntInProperty, e.EventInteger); }
public void CanRegisterEventArgsRouteWithReferenceConverter() { OutComponent outComponent = new OutComponent(); InComponent inComponent = new InComponent(); TestEventArgs e = new TestEventArgs("RouteOut", 100); TestEventArgsToStringRouteConverter converter = new TestEventArgsToStringRouteConverter(); EventToMethodRoute route = EventToMethodRoute.Create <string>(outComponent, "TestEventOut", inComponent, (x) => inComponent.StringActionIn(x), converter); route.RegisterRoute(); if (!route.IsRegistered) { Assert.Fail("Route not registered."); } outComponent.RaiseTestEventOut(e); route.UnregisterRoute(); Assert.IsTrue(string.Compare(e.EventString, inComponent.StringInProperty, false) == 0); }