public void TargetType()
		{
			SideEffectObject target = new SideEffectObject();
			IDynamicMock mock = new DynamicMock(typeof (IObjectFactory));
			mock.ExpectAndReturn("IsPrototype", true, null);
			mock.ExpectAndReturn("GetType", typeof(SideEffectObject), null);
			PrototypeTargetSource source = new PrototypeTargetSource();
			source.ObjectFactory = (IObjectFactory) mock.Object;
			Assert.AreEqual(target.GetType(), source.TargetType, "Wrong TargetType being returned.");
			mock.Verify();
		}
		public void testIntroductionInterceptorWithDelegation()
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ITimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);
	
			IDynamicMock tsControl = new DynamicMock(typeof(ITimeStampedIntroduction));
			ITimeStampedIntroduction ts = (ITimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			factory.AddIntroduction(advisor);

			ITimeStamped tsp = (ITimeStamped) factory.GetProxy();
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);
	
			tsControl.Verify();
		}
        public void ErrorsWhileGettingTheReferenceToTheServiceAreVisibleToTheUser ()
        {
            DynamicMock mockFactory = new DynamicMock(typeof(ISpringServiceFactory));
            DynamicMock mockService = new DynamicMock(typeof(ISpringService));

            mockService.ExpectAndThrow("DeployInformations", new Exception("this and that"));
            mockFactory.ExpectAndReturn("SpringService", mockService.Object);

            monitor.ServiceFactory = mockFactory.Object as ISpringServiceFactory;
            Assert.AreEqual("service not available: this and that", serviceStatus.Text);
            Assert.AreEqual(String.Empty, appStatus.Text);
            ScreenShot ("service not available.gif");
        }
		public void WithNonSingletonTargetObject()
		{
			IDynamicMock mock = new DynamicMock(typeof (IObjectFactory));
			const string objectName = "Foo";
			mock.ExpectAndReturn("IsPrototype", false, objectName);
			PrototypeTargetSource source = new PrototypeTargetSource();
			source.TargetObjectName = objectName;
			try
			{
				source.ObjectFactory = (IObjectFactory) mock.Object;
				Assert.Fail("Should have thrown an ObjectDefinitionStoreException by this point.");
			}
			catch (ObjectDefinitionStoreException)
			{
				mock.Verify();
			}
		}
		public void GetTarget()
		{
			SideEffectObject target = new SideEffectObject();
			IDynamicMock mock = new DynamicMock(typeof (IObjectFactory));;
			mock.ExpectAndReturn("IsPrototype", true, "foo");
			mock.ExpectAndReturn("GetObject", target, "foo");
		    mock.ExpectAndReturn("GetType", typeof (string), "foo");
			PrototypeTargetSource source = new PrototypeTargetSource();
            source.TargetObjectName = "foo";
			source.ObjectFactory = (IObjectFactory) mock.Object;
			Assert.IsTrue(object.ReferenceEquals(source.GetTarget(), target),
			              "Initial target source reference not being returned by GetTarget().");
			mock.Verify();
		}
		public void testIntroductionInterceptorWithInterfaceHierarchy() 
		{
			TestObject raw = new TestObject();
			Assert.IsTrue(! (raw is ISubTimeStamped));
			ProxyFactory factory = new ProxyFactory(raw);

			IDynamicMock tsControl = new DynamicMock(typeof(ISubTimeStampedIntroduction));
			ISubTimeStampedIntroduction ts = (ISubTimeStampedIntroduction) tsControl.Object;
			tsControl.ExpectAndReturn("TimeStamp", EXPECTED_TIMESTAMP);

			DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(ts);
			// we must add introduction, not an advisor
			factory.AddIntroduction(advisor);

			object proxy = factory.GetProxy();
			ISubTimeStamped tsp = (ISubTimeStamped) proxy;
			Assert.IsTrue(tsp.TimeStamp == EXPECTED_TIMESTAMP);

			tsControl.Verify();
		}