public void GetTarget()
        {
            IObjectFactory   factory = A.Fake <IObjectFactory>();
            SideEffectObject target  = new SideEffectObject();

            A.CallTo(() => factory.IsPrototype("foo")).Returns(true);
            A.CallTo(() => factory.GetObject("foo")).Returns(target);
            A.CallTo(() => factory.GetType("foo")).Returns(typeof(string));

            PrototypeTargetSource source = new PrototypeTargetSource();

            source.TargetObjectName = "foo";
            source.ObjectFactory    = factory;
            Assert.IsTrue(object.ReferenceEquals(source.GetTarget(), target),
                          "Initial target source reference not being returned by GetTarget().");
        }
示例#2
0
        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();
        }
示例#3
0
        public void GetTarget()
        {
            MockRepository mocks = new MockRepository();

            IObjectFactory   factory = mocks.CreateMock <IObjectFactory>();
            SideEffectObject target  = new SideEffectObject();

            using (mocks.Record())
            {
                Expect.Call(factory.IsPrototype("foo")).Return(true);
                Expect.Call(factory.GetObject("foo")).Return(target);
                Expect.Call(factory.GetType("foo")).Return(typeof(string));
            }

            using (mocks.Playback())
            {
                PrototypeTargetSource source = new PrototypeTargetSource();
                source.TargetObjectName = "foo";
                source.ObjectFactory    = factory;
                Assert.IsTrue(object.ReferenceEquals(source.GetTarget(), target),
                              "Initial target source reference not being returned by GetTarget().");
            }
        }
        public void GetTarget()
        {
            MockRepository mocks = new MockRepository();

            IObjectFactory factory = mocks.CreateMock<IObjectFactory>();
            SideEffectObject target = new SideEffectObject();

            using (mocks.Record())
            {
                Expect.Call(factory.IsPrototype("foo")).Return(true);
                Expect.Call(factory.GetObject("foo")).Return(target);
                Expect.Call(factory.GetType("foo")).Return(typeof(string));
            }

            using (mocks.Playback())
            {
                PrototypeTargetSource source = new PrototypeTargetSource();
                source.TargetObjectName = "foo";
                source.ObjectFactory = factory;
                Assert.IsTrue(object.ReferenceEquals(source.GetTarget(), target),
                              "Initial target source reference not being returned by GetTarget().");
            }

        }
		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();
		}