public void ReplaceWhenCreating() { var listener = new ReplaceUponCreationListener(); _context.RegisterCompositionListener("replacer", listener); var c = _context.GetComponent <ISampleContract>(); Assert.IsNotNull(c); Assert.IsNotInstanceOfType(c, typeof(SampleComponentOne)); Assert.IsInstanceOfType(c, typeof(SampleComponentTwo)); }
public void CountEventsGetShared() { _context.Register(typeof(SharedComponent)); var listener = new CountingCompositionListener(); _context.RegisterCompositionListener("counter", listener); _context.GetComponent <ISampleContract>(); _context.GetComponent <ISampleContract>(); _context.GetComponent <ISampleContract>(); Assert.AreEqual(1, listener.OnComponentCreatedCount); Assert.AreEqual(1, listener.OnComponentComposedCount); Assert.AreEqual(3, listener.OnComponentRetrievedCount); }
public void TestInitialize() { _context = new ComponentContext(); _context.Register(typeof(SampleComponentOne)); _listener = new ParameterRecorderListener(); _context.RegisterCompositionListener("recorder", _listener); _context.GetComponent <ISampleContract>(); }
public void NullNameThrows() { _context.RegisterCompositionListener(null, null); }