Exemple #1
0
 public void TestObjectProxyCloneObject()
 {
     ObjectProxy proxy = new ObjectProxy(typeof(TestClass1));
     TestClass1 instance = new TestClass1(7L, "test");
     TestClass1 other = (TestClass1)proxy.CloneObject(instance);
     Assert.IsNotNull(other);
     Assert.AreEqual(7L, other.Id);
     Assert.AreEqual("test", other.Name);
 }
Exemple #2
0
 public void TestObjectProxyGetValue()
 {
     ObjectProxy proxy = new ObjectProxy(typeof(TestClass1));
     TestClass1 instance = new TestClass1(7L, "test");
     Assert.AreEqual(7L, proxy.GetValue(instance, "id"));
     Assert.AreEqual(7L, proxy.GetValue(instance, "Id"));
     Assert.AreEqual(7L, proxy.GetValue(instance, "ID"));
     Assert.AreEqual("test", proxy.GetValue(instance, "name"));
     Assert.AreEqual("test", proxy.GetValue(instance, "Name"));
     Assert.AreEqual("test", proxy.GetValue(instance, "NAME"));
 }
Exemple #3
0
 public void TestObjectProxyIsDefaultProperties()
 {
     ObjectProxy proxy = new ObjectProxy(typeof(TestClass2));
     TestClass2 instance2 = new TestClass2();
     Assert.IsTrue(proxy.IsDefaultProperties(instance2));
     instance2.Age = 7;
     Assert.IsFalse(proxy.IsDefaultProperties(instance2));
     proxy = new ObjectProxy(typeof(TestClass1));
     TestClass1 instance1 = new TestClass1();
     Assert.IsTrue(proxy.IsDefaultProperties(instance1));
     instance1.Id = 7;
     Assert.IsFalse(proxy.IsDefaultProperties(instance1));
 }
Exemple #4
0
 public void TestObjectProxyWriteToStringMap()
 {
     TestClass1 instance = new TestClass1(7L, "test");
     ObjectProxy proxy = new ObjectProxy(typeof(TestClass1));
     Dictionary<string, string> map = proxy.WriteToStringMap(instance);
     Assert.IsNotNull(map);
     Assert.AreEqual(2, map.Count);
     Assert.AreEqual("7", map["Id"]);
     Assert.AreEqual("test", map["Name"]);
 }
Exemple #5
0
 public void TestObjectProxySetValue()
 {
     ObjectProxy proxy = new ObjectProxy(typeof(TestClass1));
     TestClass1 instance = new TestClass1();
     proxy.SetValue(instance, "id", 7L);
     Assert.AreEqual(7L, instance.Id);
     proxy.SetValue(instance, "Id", 7L);
     Assert.AreEqual(7L, instance.Id);
     proxy.SetValue(instance, "id", 9);
     Assert.AreEqual(9L, instance.Id);
     proxy.SetValue(instance, "id", "11");
     Assert.AreEqual(11L, instance.Id);
     proxy.SetValue(instance, "name", "test");
     Assert.AreEqual("test", instance.Name);
     proxy.SetValue(instance, "Name", "test");
     Assert.AreEqual("test", instance.Name);
 }
Exemple #6
0
 public void TestObjectProxyReadFromStringMap()
 {
     // Normal Test
     Dictionary<string, string> map = new Dictionary<string, string>();
     map.Add("Id", "7");
     map.Add("Name", "test");
     ObjectProxy proxy = new ObjectProxy(typeof(TestClass1));
     TestClass1 instance = new TestClass1();
     proxy.ReadFromStringMap(instance, map);
     Assert.AreEqual(7L, instance.Id);
     Assert.AreEqual("test", instance.Name);
     // Lower Case Test
     map = new Dictionary<string, string>();
     map.Add("id", "7");
     map.Add("name", "test");
     instance = new TestClass1();
     proxy.ReadFromStringMap(instance, map);
     Assert.AreEqual(7L, instance.Id);
     Assert.AreEqual("test", instance.Name);
 }
 public void TestObjectProxyFactoryToStringMap()
 {
     TestClass1 instance = new TestClass1(7L, "test");
     Dictionary<string, string> map = ObjectProxyFactory.ToStringMap(instance);
     Assert.IsNotNull(map);
     Assert.AreEqual(2, map.Count);
     Assert.AreEqual("7", map["Id"]);
     Assert.AreEqual("test", map["Name"]);
 }
 public void TestObjectProxyFactoryMap()
 {
     TestClass1 source = new TestClass1(7L, "hola");
     TestClass3 target = ObjectProxyFactory.MapTo<TestClass3>(source);
     Assert.AreEqual(source.Id, target.ObjectId);
     Assert.AreEqual(source.Name, target.NameTxt);
     TestClass1 newSource = ObjectProxyFactory.MapTo<TestClass1>(target);
     Assert.AreEqual(source.Id, newSource.Id);
     Assert.AreEqual(source.Name, newSource.Name);
 }
 public void TestObjectProxyFactoryGetProxy()
 {
     IObjectProxy proxy1 = ObjectProxyFactory.Get<TestClass1>();
     Assert.IsNotNull(proxy1);
     Assert.AreEqual(typeof(TestClass1), proxy1.ProxyType);
     IObjectProxy proxy2 = ObjectProxyFactory.GetByType(typeof(TestClass1));
     Assert.AreSame(proxy1, proxy2);
     TestClass1 instance = new TestClass1();
     IObjectProxy proxy3 = ObjectProxyFactory.Get(instance);
     Assert.AreSame(proxy1, proxy3);
 }