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 RetrieveModifiers() { TesteObj obj = new TesteObj(); obj.SetWhere("Idade > 18"); Assert.IsTrue(obj.retrieve("Nome", "teste"), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE Nome LIKE 'teste' AND Idade > 18", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); obj.SetOrderBy("Nome,Idade"); Assert.IsTrue(obj.retrieve("PesoKg", 50), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 50 AND Idade > 18 ORDER BY Nome,Idade", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); obj.SetGroupBy("Idade,Nome,PesoKg,Teste1,Cod"); Assert.IsTrue(obj.retrieve("PesoKg", 50), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 50 AND Idade > 18 GROUP BY Idade,Nome,PesoKg,Teste1,Cod ORDER BY Nome,Idade", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); obj.SetLimit("10"); Assert.IsTrue(obj.retrieve("PesoKg", 50), "DataObject retrieve"); Assert.AreEqual("SELECT TOP 10 Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 50 AND Idade > 18 GROUP BY Idade,Nome,PesoKg,Teste1,Cod ORDER BY Nome,Idade", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); obj.SetWhere(null); Assert.IsTrue(obj.retrieve("PesoKg", 50), "DataObject retrieve"); Assert.AreEqual("SELECT TOP 10 Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 50 GROUP BY Idade,Nome,PesoKg,Teste1,Cod ORDER BY Nome,Idade", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); obj.SetLimit(null); obj.SetGroupBy(""); Assert.IsTrue(obj.retrieve("PesoKg", 50), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 50 ORDER BY Nome,Idade", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "DataObject retrieve"); obj.SetOrderBy(""); Assert.IsTrue(obj.retrieve("PesoKg", 50), "DataObject retrieve"); Assert.AreEqual("SELECT Cod,Nome,Idade,PesoKg,Aniversario,Teste1,Ativo FROM TesteObj WHERE PesoKg = 50", ((MockDriver)Conf.Driver).getPreviousCommand().CommandText, "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"); }