public void OverrideChangesFactory() { IQueueManagerFactory newFactory = mocks.Create <IQueueManagerFactory>(MockBehavior.Strict).Object; IQueueManager newManager = mocks.Create <IQueueManager>(MockBehavior.Strict).Object; Mock.Get(newFactory).Setup(_newFactory => _newFactory.Create(null, null, null)).Returns(newManager).Verifiable(); IntegrationQueueManagerFactory.OverrideFactory(newFactory); try { object instance = IntegrationQueueManagerFactory.CreateManager(null, null, null); Assert.AreSame(newManager, instance); } finally { // Clean up - otherwise the static instance will be corrected IntegrationQueueManagerFactory.ResetFactory(); } mocks.VerifyAll(); }
public void OverrideChangesFactory() { IQueueManagerFactory newFactory = mocks.StrictMock <IQueueManagerFactory>(); IQueueManager newManager = mocks.StrictMock <IQueueManager>(); Expect.Call(newFactory.Create(null, null, null)).Return(newManager); mocks.ReplayAll(); IntegrationQueueManagerFactory.OverrideFactory(newFactory); try { object instance = IntegrationQueueManagerFactory.CreateManager(null, null, null); Assert.AreSame(newManager, instance); } finally { // Clean up - otherwise the static instance will be corrected IntegrationQueueManagerFactory.ResetFactory(); } mocks.VerifyAll(); }
public void Teardown() { IntegrationQueueManagerFactory.ResetFactory(); }