public void TestAnotherTypeSetter()
 {
     var builder = new DynamicProxyBuilder("RecycleBin.DynamicProxy.Proxy");
      var person = new Person("Alice", new DateTime(2000, 10, 2));
      var proxy = (IPerson)builder.CreateProxy(typeof(IPerson), person);
      Assert.That(proxy.AnotherTypeProperty = null, Throws.TypeOf<NotSupportedException>());
 }
 public void TestAnotherTypeMethod()
 {
     var builder = new DynamicProxyBuilder("RecycleBin.DynamicProxy.Proxy");
      var person = new Person("Alice", new DateTime(2000, 10, 2));
      var proxy = (IPerson)builder.CreateProxy(typeof(IPerson), person);
      proxy.AnotherTypeMethod(null);
 }
 public void TestWrongTarget()
 {
     var builder = new DynamicProxyBuilder("RecycleBin.DynamicProxy.Proxy");
      var person = new Person("Alice", new DateTime(2000, 10, 2));
      var proxy = (IPerson)builder.CreateProxy(typeof(IPerson), person);
      Assert.That(proxy[1, 2], Throws.TypeOf<NotSupportedException>());
 }
 public void TestProxy()
 {
     var builder = new DynamicProxyBuilder("RecycleBin.DynamicProxy.Proxy");
      var person = new Person("Alice", new DateTime(2000, 10, 2));
      var proxy = (IPerson)builder.CreateProxy(typeof(IPerson), person);
      Assert.That(proxy, Is.Not.Null);
      Assert.That(proxy.Name, Is.EqualTo(person.Name));
      Assert.That(proxy.Date, Is.EqualTo(person.Birthday));
      Assert.That(proxy[1], Is.EqualTo(person[1]));
      var today = DateTime.Now;
      Assert.That(proxy.GetValue(today), Is.EqualTo(person.GetAge(today)));
      person.Name = "Bob";
      Assert.That(proxy.Name, Is.EqualTo("Bob"));
 }