public void FindFetch() { TesteObj obj = new TesteObj(); obj.ID = 1; obj.Nome = "teste"; obj.TesteObj3 = new TesteObj3(); obj.TesteObj3.ID = 5; Assert.IsTrue(obj.find(), "DataObject find"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE (Cod = 1) ", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject cannot select from table"); Assert.IsTrue(obj.fetch(), "DataObject fetch from DataReader"); obj = new TesteObj(); obj.Nome = "teste"; obj.Idade = 18; obj.Peso = 60.5; obj.TesteObj3 = new TesteObj3(); obj.TesteObj3.ID = 5; Assert.IsTrue(obj.find(), "DataObject find"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE (Nome LIKE 'teste') AND (Idade = 18) AND (PesoKg = 60.5) AND (Teste1 = 5) ", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject cannot select from table"); }
public void Retrieve() { TesteObj obj = new TesteObj(); Assert.IsTrue(obj.retrieve("Nome", "teste1"), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Nome LIKE 'teste1'", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(1, obj.ID, "DataObject retrieve #1"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.IsNull(obj.TesteObj3, "DataObject retrieve"); Assert.IsTrue(obj.Ativo, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("Cod", 1), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Cod = 1", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(1, obj.ID, "DataObject retrieve #2"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.IsNull(obj.TesteObj3, "DataObject retrieve"); Assert.IsTrue(obj.Ativo, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("ID", 1), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Cod = 1", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(1, obj.ID, "DataObject retrieve #3"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.IsNull(obj.TesteObj3, "DataObject retrieve"); Assert.IsTrue(obj.Ativo, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("Peso", 60.5), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 60.5", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(1, obj.ID, "DataObject retrieve #4"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.IsNull(obj.TesteObj3, "DataObject retrieve"); Assert.IsTrue(obj.Ativo, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("PesoKg", 60.5), "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 60.5", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.AreEqual(1, obj.ID, "DataObject retrieve #5"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.IsNull(obj.TesteObj3, "DataObject retrieve"); Assert.IsTrue(obj.Ativo, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); obj = new TesteObj(); Assert.IsTrue(obj.retrieve("Idade", 18), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Idade = 18", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); Assert.IsTrue(obj.fetch(), "DataObject fetch"); Assert.AreEqual(1, obj.ID, "DataObject retrieve #6"); Assert.AreEqual(18, obj.Idade, "DataObject retrieve"); Assert.AreEqual(60.5, obj.Peso, "DataObject retrieve"); Assert.IsNull(obj.TesteObj3, "DataObject retrieve"); Assert.IsTrue(obj.Ativo, "DataObject retrieve"); Assert.AreEqual("teste1", obj.Nome, "DataObject retrieve"); }
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"); }