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 WithNonSingletonTargetObject()
        {
            IObjectFactory factory    = A.Fake <IObjectFactory>();
            const string   objectName = "Foo";

            A.CallTo(() => factory.IsPrototype(objectName)).Returns(false);
            PrototypeTargetSource source = new PrototypeTargetSource();

            source.TargetObjectName = objectName;

            Assert.Throws <ObjectDefinitionStoreException>(delegate { source.ObjectFactory = factory; });
        }
Esempio n. 3
0
        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 TargetType()
        {
            SideEffectObject target = new SideEffectObject();

            IObjectFactory factory = A.Fake <IObjectFactory>();

            A.CallTo(() => factory.IsPrototype(null)).Returns(true);
            A.CallTo(() => factory.GetType(null)).Returns(typeof(SideEffectObject));

            PrototypeTargetSource source = new PrototypeTargetSource();

            source.ObjectFactory = factory;
            Assert.AreEqual(target.GetType(), source.TargetType, "Wrong TargetType being returned.");
        }
Esempio n. 5
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();
        }
        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().");
        }
Esempio n. 7
0
        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();
            }
        }
Esempio n. 8
0
        public void WithNonSingletonTargetObject()
        {
            MockRepository mocks = new MockRepository();

            IObjectFactory factory    = mocks.CreateMock <IObjectFactory>();
            const string   objectName = "Foo";

            using (mocks.Record())
            {
                Expect.Call(factory.IsPrototype(objectName)).Return(false);
            }

            using (mocks.Playback())
            {
                PrototypeTargetSource source = new PrototypeTargetSource();
                source.TargetObjectName = objectName;

                Assert.Throws <ObjectDefinitionStoreException>(delegate { source.ObjectFactory = factory; });
            }
        }
Esempio n. 9
0
        public void TargetType()
        {
            MockRepository   mocks  = new MockRepository();
            SideEffectObject target = new SideEffectObject();

            IObjectFactory factory = mocks.CreateMock <IObjectFactory>();

            using (mocks.Record())
            {
                Expect.Call(factory.IsPrototype(null)).Return(true);
                Expect.Call(factory.GetType(null)).Return(typeof(SideEffectObject));
            }

            using (mocks.Playback())
            {
                PrototypeTargetSource source = new PrototypeTargetSource();
                source.ObjectFactory = factory;
                Assert.AreEqual(target.GetType(), source.TargetType, "Wrong TargetType being returned.");
            }
        }
Esempio n. 10
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 AfterPropertiesSetWithoutTargetObjectNameBeingSet()
 {
     PrototypeTargetSource source = new PrototypeTargetSource();
     source.AfterPropertiesSet();
 }
        public void TargetType()
        {
            MockRepository mocks = new MockRepository();
            SideEffectObject target = new SideEffectObject();

            IObjectFactory factory = mocks.CreateMock<IObjectFactory>();

            using (mocks.Record())
            {
                Expect.Call(factory.IsPrototype(null)).Return(true);
                Expect.Call(factory.GetType(null)).Return(typeof(SideEffectObject));
            }

            using (mocks.Playback())
            {
                PrototypeTargetSource source = new PrototypeTargetSource();
                source.ObjectFactory = factory;
                Assert.AreEqual(target.GetType(), source.TargetType, "Wrong TargetType being returned.");
            }

        }
        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 WithNonSingletonTargetObject()
        {
            MockRepository mocks = new MockRepository();

            IObjectFactory factory = mocks.CreateMock<IObjectFactory>();
            const string objectName = "Foo";

            using (mocks.Record())
            {
                Expect.Call(factory.IsPrototype(objectName)).Return(false);
            }

            using (mocks.Playback())
            {
                PrototypeTargetSource source = new PrototypeTargetSource();
                source.TargetObjectName = objectName;

                Assert.Throws<ObjectDefinitionStoreException>(delegate { source.ObjectFactory = factory; });
            }
        }
 public void IsStatic()
 {
     PrototypeTargetSource source = new PrototypeTargetSource();
     Assert.IsFalse(source.IsStatic, "Must not be static.");
 }
		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 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 AfterPropertiesSetWithoutTargetObjectNameBeingSet()
        {
            PrototypeTargetSource source = new PrototypeTargetSource();

            Assert.Throws <ArgumentNullException>(() => source.AfterPropertiesSet());
        }
Esempio n. 19
0
        public void AfterPropertiesSetWithoutTargetObjectNameBeingSet()
        {
            PrototypeTargetSource source = new PrototypeTargetSource();

            source.AfterPropertiesSet();
        }
        public void IsStatic()
        {
            PrototypeTargetSource source = new PrototypeTargetSource();

            Assert.IsFalse(source.IsStatic, "Must not be static.");
        }
 public void AfterPropertiesSetWithoutTargetObjectNameBeingSet()
 {
     PrototypeTargetSource source = new PrototypeTargetSource();
     Assert.Throws<ArgumentNullException>(() => source.AfterPropertiesSet());
 }