public void Register_ExternalInstance_RetrieveSame() { Registry reg = new Registry("test"); DummyObjectLow instance = new DummyObjectLow(); reg.Register <IDummyObjectInterface> (instance, 0); IDummyObjectInterface o1 = reg.Retrieve <IDummyObjectInterface> (InstanceType.Default); IDummyObjectInterface o2 = reg.Retrieve <IDummyObjectInterface> (InstanceType.Default); Assert.IsNotNull(o1); Assert.IsNotNull(o2); Assert.AreSame(o1, o2); }
public void TestRetrieveSameInstance() { Registry reg = new Registry("test"); reg.Register <IDummyObjectInterface, DummyObjectLow> (0); IDummyObjectInterface o1 = reg.Retrieve <IDummyObjectInterface> (InstanceType.Default); IDummyObjectInterface o2 = reg.Retrieve <IDummyObjectInterface> (InstanceType.Default); IDummyObjectInterface o3 = reg.Retrieve <IDummyObjectInterface> (InstanceType.New); Assert.IsNotNull(o1); Assert.IsNotNull(o2); Assert.AreSame(o1, o2); Assert.AreNotSame(o1, o3); }
public void TestRetrieveNewInstance() { Registry reg = new Registry("test"); reg.Register <IDummyObjectInterface, DummyObjectLow> (0); reg.Register <IDummyObjectInterface, DummyObjectHigh> (1); IDummyObjectInterface o1 = reg.Retrieve <IDummyObjectInterface> (InstanceType.New); IDummyObjectInterface o2 = reg.Retrieve <IDummyObjectInterface> (InstanceType.New); Assert.IsNotNull(o1); Assert.IsNotNull(o2); Assert.IsInstanceOf(typeof(DummyObjectHigh), o1); Assert.IsInstanceOf(typeof(DummyObjectHigh), o2); Assert.AreNotSame(o1, o2); }