SetField() public method

public SetField ( string col, object val ) : void
col string
val object
return void
Ejemplo n.º 1
0
        public void SetField()
        {
            TesteObj obj = new TesteObj();
            obj.ID = 2;
            obj.Nome = "teste 2";
            obj.SetField("Cod", 1);
            obj.SetField("Nome", "teste");
            obj.SetField("PesoKg", 60.5);
            obj.SetField("Idade", 18);
            obj.SetField("Ativo", true);

            Assert.AreEqual(1, obj.ID, "DataObject cannot set Field 'ID'");
            Assert.AreEqual("teste", obj.Nome, "DataObject cannot set Field 'Nome'");
            Assert.AreEqual(60.5, obj.Peso, "DataObject cannot set Field 'Peso'");
            Assert.AreEqual(18, obj.Idade, "DataObject cannot set Field 'Idade'");
            Assert.IsTrue(obj.Ativo, "DataObject cannot set Field 'Ativo'");
            obj.SetField("ID", 2);
            Assert.AreEqual(2, obj.ID, "DataObject cannot set Field 'ID'");
            obj.SetField("Peso", 61.5);
            Assert.AreEqual(61.5, obj.Peso, "DataObject cannot set Field 'Peso'");
            obj.SetField("Ativo", false);
            Assert.IsFalse(obj.Ativo, "DataObject cannot set Field 'Ativo'");
            obj.SetField("Ativo", "T");
            Assert.IsTrue(obj.Ativo, "DataObject cannot set Field 'Ativo'");
            obj.SetField("Ativo", "F");
            Assert.IsFalse(obj.Ativo, "DataObject cannot set Field 'Ativo'");
        }
Ejemplo n.º 2
0
 public void SetFieldError()
 {
     TesteObj obj = new TesteObj();
     obj.ID = 1;
     obj.Nome = "teste";
     obj.SetField("Codigo", 2);
 }
Ejemplo n.º 3
0
        public void SetField()
        {
            TesteObj obj = new TesteObj();
            obj.ID = 2;
            obj.Nome = "teste 2";
            TesteObj3 obj3 = new TesteObj3();
            obj3.ID = 5;
            obj.SetField("Teste1", obj3);

            Assert.AreEqual(obj3, obj.TesteObj3, "DataObject cannot set Field 'Nome'");
            obj.SetField("Teste1", 1);
            Assert.IsNull(obj.TesteObj3, "DataObject cannot set Field 'Teste1'");
            obj.SetField("Teste1", 5);
            Assert.AreEqual(5, obj.TesteObj3.ID, "DataObject cannot set Field 'Teste1'");
            obj3 = new TesteObj3();
            obj3.ID = 10;
            obj.SetField("TesteObj3", obj3);
            Assert.AreEqual(obj3, obj.TesteObj3, "DataObject cannot set Field 'TesteObj3'");
        }