public void SimpleRegister() { _context.ForComponent <NonAttributedComponent>().RegisterWith <INonAttributedContract>(); var c = _context.GetComponent <INonAttributedContract>(); Assert.IsNotNull(c); }
public void DirectClosedGeneric() { _context.ForComponent <ClosedGenericComponent>() .RegisterWith <IGenericContract <string> >(); var c = _context.GetComponent <IGenericContract <string> >(); Assert.IsNotNull(c); }
public void RegisterWithDefaultCache() { _context.ForComponent <NonAttributedComponent>().RegisterWith <INonAttributedContract>(); var c1 = _context.GetComponent <INonAttributedContract>(); var c2 = _context.GetComponent <INonAttributedContract>(); Assert.IsNotNull(c1); Assert.IsNotNull(c2); Assert.IsTrue(ReferenceEquals(c1, c2)); }
public void AddInitializationMethod() { _context.ForComponent <NonAttributedComponent>() .NotifyInitialized((cmpsr, x) => x.Initialize()) .RegisterWith <INonAttributedContract>(); var i = _context.GetComponent <INonAttributedContract>(); var c = i as NonAttributedComponent; Assert.IsNotNull(i); Assert.IsNotNull(c); Assert.IsTrue(c.InitCalled); }
public void QueryComponentPlugs() { _context.ForComponent <NonAttributedComponent>() .SetComponent(x => x.ComponentOne) .SetComponent(x => x.ComponentTwo) .RegisterWith <INonAttributedContract>(); var i = _context.GetComponent <INonAttributedContract>(); var c = i as NonAttributedComponent; Assert.IsNotNull(i); Assert.IsNotNull(c); Assert.IsNotNull(c.ComponentOne); Assert.IsNotNull(c.ComponentTwo); }
public void SetValue() { _context.ForComponent <NonAttributedComponent>() .SetValue(x => x.SomeValue, "someString") .SetValue(x => x.SomeOtherValue, 5) .RegisterWith <INonAttributedContract>(); var i = _context.GetComponent <INonAttributedContract>(); var c = i as NonAttributedComponent; Assert.IsNotNull(i); Assert.IsNotNull(c); Assert.AreEqual("someString", c.SomeValue); Assert.AreEqual(5, c.SomeOtherValue); }
public void ConstructorComponent() { _context.ForComponent <NonAttributedComponent>() .AddConstructorComponent <IComponentOne>() .AddConstructorComponent <IComponentTwo>("name") .RegisterWith <INonAttributedContract>(); var i = _context.GetComponent <INonAttributedContract>(); var c = i as NonAttributedComponent; Assert.IsNotNull(i); Assert.IsNotNull(c); Assert.IsNotNull(c.ComponentOne); Assert.IsNotNull(c.ComponentTwo); }