public void NullTargetObjectName()
        {
            ObjectReferenceFactoryObject fac = new ObjectReferenceFactoryObject();

            // simulate IFactoryObjectAware interface...
            Assert.Throws <ArgumentException>(() => fac.ObjectFactory = null);
        }
        public void WhitespaceTargetObjectName()
        {
            ObjectReferenceFactoryObject fac = new ObjectReferenceFactoryObject();

            fac.TargetObjectName = string.Empty;
            // simulate IFactoryObjectAware interface...
            Assert.Throws <ArgumentException>(() => fac.ObjectFactory = null);
        }
        public void DelegatesThroughToFactoryFor_IsSingleton()
        {
            Expect.Call(factory.ContainsObject("bojangles")).Return(true);
            Expect.Call(factory.IsSingleton("bojangles")).Return(true);
            mocks.ReplayAll();

            ObjectReferenceFactoryObject fac = new ObjectReferenceFactoryObject();

            fac.TargetObjectName = "bojangles";
            fac.ObjectFactory    = factory;

            Assert.IsTrue(fac.IsSingleton);
            mocks.VerifyAll();
        }
        public void DelegatesThroughToFactoryFor_ObjectType()
        {
            Expect.Call(factory.ContainsObject("bojangles")).Return(true);
            Expect.Call(factory.GetType("bojangles")).Return(GetType());
            mocks.ReplayAll();

            ObjectReferenceFactoryObject fac = new ObjectReferenceFactoryObject();

            fac.TargetObjectName = "bojangles";
            fac.ObjectFactory    = factory;

            Assert.AreEqual(GetType(), fac.ObjectType);
            mocks.VerifyAll();
        }
        public void FactoryDoesNotContainTargetObject()
        {
            Expect.Call(factory.ContainsObject("bojangles")).Return(false);
            mocks.ReplayAll();

            ObjectReferenceFactoryObject fac = new ObjectReferenceFactoryObject();

            fac.TargetObjectName = "bojangles";
            try
            {
                // simulate IFactoryObjectAware interface...
                fac.ObjectFactory = factory;
                Assert.Fail("Must have bailed with a " +
                            "NoSuchObjectDefinitionException 'cos the object doesn't " +
                            "exist in the associated factory.");
            }
            catch (NoSuchObjectDefinitionException)
            {
                mocks.VerifyAll();
            }
        }