public void BadDelegateType() { DelegateFactoryObject fob = new DelegateFactoryObject(); fob.DelegateType = DBNull.Value.GetType(); Assert.Throws <ArgumentException>(() => fob.AfterPropertiesSet()); }
public void BadDelegateType() { DelegateFactoryObject fob = new DelegateFactoryObject(); fob.DelegateType = DBNull.Value.GetType(); fob.AfterPropertiesSet(); }
public void NullMethodName() { DelegateFactoryObject fob = new DelegateFactoryObject(); fob.DelegateType = typeof(EventHandler); fob.TargetType = typeof(OneThirstyDude); 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 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()); }
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()); }
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(); 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 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)); }
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 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 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 MissingDelegateType() { DelegateFactoryObject fob = new DelegateFactoryObject(); 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 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 MissingDelegateType() { DelegateFactoryObject fob = new DelegateFactoryObject(); Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet()); }
public void BadDelegateType() { DelegateFactoryObject fob = new DelegateFactoryObject(); fob.DelegateType = DBNull.Value.GetType(); Assert.Throws<ArgumentException>(() => fob.AfterPropertiesSet()); }
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 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()); }
public void MissingDelegateType() { DelegateFactoryObject fob = new DelegateFactoryObject(); Assert.Throws <ArgumentException>(() => fob.AfterPropertiesSet()); }