public void DisposeCallbackIsInvokedOnDispose()
        {
            IDisposable disposable = mocks.StrictMock<IDisposable>();
            disposable.Dispose();
            LastCall.On(disposable).Repeat.Once();            
			DummyFactoryObject factory = new DummyFactoryObject(disposable);
            mocks.ReplayAll();
            factory.AfterPropertiesSet();
            factory.Dispose();
            mocks.VerifyAll();
        }
        public void DisposeCallbackIsNotInvokedOnDisposeIfInPrototypeMode()
        {
            IDisposable disposable = mocks.StrictMock<IDisposable>();           
            DummyFactoryObject factory = new DummyFactoryObject(disposable);
            mocks.ReplayAll();
            factory.IsSingleton = false;
            factory.GetObject();
            factory.Dispose();
			// in prototype mode, so the Dispose() method of the object must not be called...
            mocks.VerifyAll();
        }
        public void DisposeCallbackIsInvokedOnDispose()
        {
            IDisposable disposable = A.Fake <IDisposable>();

            DummyFactoryObject factory = new DummyFactoryObject(disposable);

            factory.AfterPropertiesSet();
            factory.Dispose();

            A.CallTo(() => disposable.Dispose()).MustHaveHappenedOnceExactly();
        }
        public void DisposeCallbackIsNotInvokedOnDisposeIfInPrototypeMode()
        {
            IDisposable        disposable = mocks.StrictMock <IDisposable>();
            DummyFactoryObject factory    = new DummyFactoryObject(disposable);

            mocks.ReplayAll();
            factory.IsSingleton = false;
            factory.GetObject();
            factory.Dispose();
            // in prototype mode, so the Dispose() method of the object must not be called...
            mocks.VerifyAll();
        }
        public void DisposeCallbackIsNotInvokedOnDisposeIfInPrototypeMode()
        {
            IDisposable        disposable = A.Fake <IDisposable>();
            DummyFactoryObject factory    = new DummyFactoryObject(disposable);

            factory.IsSingleton = false;
            factory.GetObject();
            factory.Dispose();

            // in prototype mode, so the Dispose() method of the object must not be called...
            A.CallTo(() => disposable.Dispose()).MustNotHaveHappened();
        }
        public void DisposeCallbackIsInvokedOnDispose()
        {
            IDisposable disposable = mocks.StrictMock <IDisposable>();

            disposable.Dispose();
            LastCall.On(disposable).Repeat.Once();
            DummyFactoryObject factory = new DummyFactoryObject(disposable);

            mocks.ReplayAll();
            factory.AfterPropertiesSet();
            factory.Dispose();
            mocks.VerifyAll();
        }