public void OverrideAnInstalledExtension() { Expect.Once.On(m_extensionA).Method("Attach"); Expect.Once.On(m_extensionB).Method("Attach"); Expect.Once.On(m_extensionB).Method("Detach"); Expect.Once.On(m_extensionD).Method("Attach"); ModuleExtensionCollection extensions = new ModuleExtensionCollection(); extensions.Add <IMockExtensionTypeA>(m_extensionA); extensions.Add <IMockExtensionTypeB>(m_extensionB); extensions.Add <IMockExtensionTypeC>(m_extensionC); IMockExtensionTypeA extensionA = extensions.Get <IMockExtensionTypeA>(); Assert.AreSame(m_extensionA, extensionA); IMockExtensionTypeB extensionB = extensions.Get <IMockExtensionTypeB>(); Assert.AreSame(m_extensionB, extensionB); IMockExtensionTypeC extensionC = extensions.Get <IMockExtensionTypeC>(); Assert.AreSame(m_extensionC, extensionC); extensions.Add <IMockExtensionTypeB>(m_extensionD); IMockExtensionTypeB extensionD = extensions.Get <IMockExtensionTypeB>(); Assert.AreSame(m_extensionD, extensionD); m_mockery.VerifyAllExpectationsHaveBeenMet(); }
public void AddAndGetWithGenerics() { Expect.Once.On(m_extensionA).Method("Attach"); Expect.Once.On(m_extensionB).Method("Attach"); ModuleExtensionCollection extensions = new ModuleExtensionCollection(); extensions.Add <IMockExtensionTypeA>(m_extensionA); extensions.Add <IMockExtensionTypeB>(m_extensionB); extensions.Add <IMockExtensionTypeC>(m_extensionC); IMockExtensionTypeA extensionA = extensions.Get <IMockExtensionTypeA>(); Assert.AreSame(m_extensionA, extensionA); IMockExtensionTypeB extensionB = extensions.Get <IMockExtensionTypeB>(); Assert.AreSame(m_extensionB, extensionB); IMockExtensionTypeC extensionC = extensions.Get <IMockExtensionTypeC>(); Assert.AreSame(m_extensionC, extensionC); IMockExtensionTypeD extensionD = extensions.Get <IMockExtensionTypeD>(); Assert.IsNull(extensionD); m_mockery.VerifyAllExpectationsHaveBeenMet(); }