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'"); }
public void CompareOperators() { TesteObj obj1 = new TesteObj(); obj1.ID = 1; obj1.Nome = "Obj1"; TesteObj obj2 = new TesteObj(); obj2.ID = 1; obj2.Nome = "Obj1"; TesteObj3 obj3 = new TesteObj3(); obj3.ID = 1; obj3.Nome = "Obj1"; Assert.AreEqual("CsDO.Tests.TesteObj!1".GetHashCode(), obj1.GetHashCode(), "GetHashCode() #1 failing"); Assert.AreEqual("CsDO.Tests.TesteObj!1".GetHashCode(), obj2.GetHashCode(), "GetHashCode() #2 failing"); Assert.AreEqual("CsDO.Tests.TesteObj3!1".GetHashCode(), obj3.GetHashCode(), "GetHashCode() #3 failing"); Assert.IsTrue(obj1.Equals(obj2), "Equals operator #1 failing"); Assert.IsTrue(obj2.Equals(obj1), "Equals operator #2 failing"); Assert.IsFalse(obj1.Equals(obj3), "Equals operator #3 failing"); Assert.IsTrue(obj1 == obj2, "== operator #1 failing"); Assert.IsTrue(obj2 == obj1, "== operator #2 failing"); Assert.IsFalse(obj1 == obj3, "== operator #3 failing"); Assert.IsFalse(obj1 != obj2, "!= operator #1 failing"); Assert.IsFalse(obj2 != obj1, "!= operator #2 failing"); Assert.IsTrue(obj1 != obj3, "!= operator #3 failing"); }
public void Retrieve() { Conf.DataPool.Clear(); TesteObj obj = new TesteObj(); TesteObj3 obj3 = new TesteObj3(); obj3.ID = 5; Assert.IsTrue(obj.retrieve("Teste1", obj3), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Teste1 = 5", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(5, obj.ID, "DataObject retrieve"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.AreEqual(5, obj.TesteObj3.ID, "DataObject retrieve"); Assert.AreEqual(18, obj.TesteObj3.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.TesteObj3.Peso, "DataObject retrieve"); Assert.AreEqual("teste1", obj.TesteObj3.Nome, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("Teste1", 5), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Teste1 = 5", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(5, obj.ID, "DataObject retrieve"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.AreEqual(5, obj.TesteObj3.ID, "DataObject retrieve"); Assert.AreEqual(18, obj.TesteObj3.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.TesteObj3.Peso, "DataObject retrieve"); Assert.AreEqual("teste1", obj.TesteObj3.Nome, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("TesteObj3", 5), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Teste1 = 5", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(5, obj.ID, "DataObject retrieve"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.AreEqual(5, obj.TesteObj3.ID, "DataObject retrieve"); Assert.AreEqual(18, obj.TesteObj3.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.TesteObj3.Peso, "DataObject retrieve"); Assert.AreEqual("teste1", obj.TesteObj3.Nome, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); }