public void ThrowExceptionIfMethodNotFound() { // # Arrange. var pr = new PseudoRandom(nameof(ThrowExceptionIfMethodNotFound)); var obj = new MyBaseClass(); dynamic sut = new ReachIn(obj); // # Act and Assert. // The method does not exist. Assert.Throws <Exception>( () => { sut.ThisMethodIsNotFound(pr.Int()); }); // There is a property by the same name. Assert.Throws <RuntimeBinderException>( () => { sut.MyPrivateProperty(pr.Int()); }); }
public void ThrowExceptionIfStaticMethodNotFound() { // # Arrange. var pr = new PseudoRandom(nameof(ThrowExceptionIfStaticMethodNotFound)); dynamic sut = new ReachIn(typeof(MyBaseClass)); // # Act and Assert. // The method does not exist. Assert.Throws <Exception>( () => { sut.ThisMethodIsNotFound(pr.Int()); }); // There is a property by the same name. // Trying to call it fails. Assert.Throws <RuntimeBinderException>( () => { sut.MyStaticPrivateProperty(pr.Int()); }); }