Beispiel #1
0
        public void BadDelegateType()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = DBNull.Value.GetType();
            fob.AfterPropertiesSet();
        }
Beispiel #2
0
        public void ObjectType()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            Assert.IsNotNull(fob.ObjectType, "Should never be null (should default to typeof(Delegate)) ");
            Assert.AreEqual(typeof(Delegate), fob.ObjectType, "Not defaulting to typeof(Delegate).");
        }
        public void BadDelegateType()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = DBNull.Value.GetType();
            Assert.Throws <ArgumentException>(() => fob.AfterPropertiesSet());
        }
Beispiel #4
0
        public void NullMethodName()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(EventHandler);
            fob.TargetType   = typeof(OneThirstyDude);
            fob.AfterPropertiesSet();
        }
Beispiel #5
0
        public void MissingATarget()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(EventHandler);
            fob.MethodName   = "I Love You Laura Palmer, I Really Do";
            fob.AfterPropertiesSet();
        }
        public void MissingATarget()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(EventHandler);
            fob.MethodName   = "I Love You Laura Palmer, I Really Do";
            Assert.Throws <ArgumentException>(() => fob.AfterPropertiesSet());
        }
        public void NullMethodName()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(EventHandler);
            fob.TargetType   = typeof(OneThirstyDude);
            Assert.Throws <ArgumentException>(() => fob.AfterPropertiesSet());
        }
Beispiel #8
0
        public void ChokesIfBothTargetTypeAndTargetObjectSupplied()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(PopHandler);
            fob.TargetType   = typeof(OneThirstyDude);
            fob.TargetObject = new OneThirstyDude();
            fob.MethodName   = "I Love You Laura Palmer, I Really Do";
            fob.AfterPropertiesSet();
        }
		public void StaticDelegateWithInstanceMethod()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = typeof (PopHandler);
			fob.TargetType = typeof (OneThirstyDude);
			fob.MethodName = "HandlePop";
			fob.IsSingleton = false;
			fob.AfterPropertiesSet();
            Assert.Throws<ArgumentException>(() => fob.GetObject());
		}
Beispiel #10
0
        public void StaticDelegateWithInstanceMethod()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(PopHandler);
            fob.TargetType   = typeof(OneThirstyDude);
            fob.MethodName   = "HandlePop";
            fob.IsSingleton  = false;
            fob.AfterPropertiesSet();
            fob.GetObject();
        }
		public void StaticDelegate()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = typeof (PopHandler);
			fob.TargetType = typeof (OneThirstyDude);
			fob.MethodName = "StaticHandlePop";
			fob.IsSingleton = false;
			fob.AfterPropertiesSet();
			PopHandler popper = (PopHandler) fob.GetObject();
			Assert.IsNotNull(popper);
			Assert.AreEqual(fob.MethodName, popper.Method.Name);
		}
		public void InstancePrototypeDelegate()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.IsSingleton = false;
			fob.DelegateType = typeof (PopHandler);
			OneThirstyDude dude = new OneThirstyDude();
			fob.TargetObject = dude;
			fob.MethodName = "HandlePop";
			fob.IsSingleton = false;
			fob.AfterPropertiesSet();
			PopHandler one = (PopHandler) fob.GetObject();
			PopHandler two = (PopHandler) fob.GetObject();
			Assert.IsFalse(ReferenceEquals(one, two));
		}
Beispiel #13
0
        public void StaticDelegate()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(PopHandler);
            fob.TargetType   = typeof(OneThirstyDude);
            fob.MethodName   = "StaticHandlePop";
            fob.IsSingleton  = false;
            fob.AfterPropertiesSet();
            PopHandler popper = (PopHandler)fob.GetObject();

            Assert.IsNotNull(popper);
            Assert.AreEqual(fob.MethodName, popper.Method.Name);
        }
Beispiel #14
0
        public void InstancePrototypeDelegate()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.IsSingleton  = false;
            fob.DelegateType = typeof(PopHandler);
            OneThirstyDude dude = new OneThirstyDude();

            fob.TargetObject = dude;
            fob.MethodName   = "HandlePop";
            fob.IsSingleton  = false;
            fob.AfterPropertiesSet();
            PopHandler one = (PopHandler)fob.GetObject();
            PopHandler two = (PopHandler)fob.GetObject();

            Assert.IsFalse(ReferenceEquals(one, two));
        }
		public void InstanceSingletonDelegate()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = typeof (PopHandler);
			OneThirstyDude dude = new OneThirstyDude();
			fob.TargetObject = dude;
			fob.MethodName = "HandlePop";
			fob.AfterPropertiesSet();
			PopHandler popper = (PopHandler) fob.GetObject();
			Assert.IsNotNull(popper);
			Assert.AreEqual(fob.MethodName, popper.Method.Name);
			string soda = "The Drink Of Champions";
			popper(this, soda);
			Assert.AreEqual(soda, dude.Soda);
			PopHandler other = (PopHandler) fob.GetObject();
			Assert.IsTrue(ReferenceEquals(popper, other));
		}
Beispiel #16
0
        public void InstanceSingletonDelegate()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.DelegateType = typeof(PopHandler);
            OneThirstyDude dude = new OneThirstyDude();

            fob.TargetObject = dude;
            fob.MethodName   = "HandlePop";
            fob.AfterPropertiesSet();
            PopHandler popper = (PopHandler)fob.GetObject();

            Assert.IsNotNull(popper);
            Assert.AreEqual(fob.MethodName, popper.Method.Name);
            string soda = "The Drink Of Champions";

            popper(this, soda);
            Assert.AreEqual(soda, dude.Soda);
            PopHandler other = (PopHandler)fob.GetObject();

            Assert.IsTrue(ReferenceEquals(popper, other));
        }
        public void MissingDelegateType()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            Assert.Throws <ArgumentException>(() => fob.AfterPropertiesSet());
        }
		public void MissingDelegateType()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.AfterPropertiesSet();
		}
		public void BadDelegateType()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = DBNull.Value.GetType();
			fob.AfterPropertiesSet();
		}
 public void EmptyMethodName()
 {
     DelegateFactoryObject fob = new DelegateFactoryObject();
     fob.DelegateType = typeof (EventHandler);
     fob.TargetType = typeof (OneThirstyDude);
     fob.MethodName = string.Empty;
     fob.AfterPropertiesSet();
 }
 public void WhitespacedMethodName()
 {
     DelegateFactoryObject fob = new DelegateFactoryObject();
     fob.DelegateType = typeof (EventHandler);
     fob.TargetType = typeof (OneThirstyDude);
     fob.MethodName = "\n";
     fob.AfterPropertiesSet();
 }
		public void MissingATarget()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = typeof (EventHandler);
			fob.MethodName = "I Love You Laura Palmer, I Really Do";
			fob.AfterPropertiesSet();
		}
		public void MissingDelegateType()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
            Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet());
		}
Beispiel #24
0
        public void MissingDelegateType()
        {
            DelegateFactoryObject fob = new DelegateFactoryObject();

            fob.AfterPropertiesSet();
        }
		public void BadDelegateType()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = DBNull.Value.GetType();
            Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet());
		}
		public void ObjectType()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			Assert.IsNotNull(fob.ObjectType, "Should never be null (should default to typeof(Delegate)) ");
			Assert.AreEqual(typeof (Delegate), fob.ObjectType, "Not defaulting to typeof(Delegate).");
		}
 public void WhitespacedMethodName()
 {
     DelegateFactoryObject fob = new DelegateFactoryObject();
     fob.DelegateType = typeof (EventHandler);
     fob.TargetType = typeof (OneThirstyDude);
     fob.MethodName = "\n";
     Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet());
 }
		public void MissingATarget()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = typeof (EventHandler);
			fob.MethodName = "I Love You Laura Palmer, I Really Do";
            Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet());
		}
		public void ChokesIfBothTargetTypeAndTargetObjectSupplied()
		{
			DelegateFactoryObject fob = new DelegateFactoryObject();
			fob.DelegateType = typeof (PopHandler);
			fob.TargetType = typeof (OneThirstyDude);
			fob.TargetObject = new OneThirstyDude();
			fob.MethodName = "I Love You Laura Palmer, I Really Do";
            Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet());
		}