public void GeraInsertCategoriaTeste()
        {
            CategoriaTeste categoria = new CategoriaTeste();
            categoria.Id = 2;
            categoria.Nome = "Comidas";

            target = new CommandInsertGenerator(categoria);

            string insert = "INSERT INTO categoria_teste (nome) VALUES ('Comidas')";

            Assert.That(target.GetCommand(), Is.EqualTo(insert));
        }
        public void AdicionaInstanciaCategoriaTesteAoDicionario()
        {
            Assert.That(target.CountObjects, Is.EqualTo(0));

            CategoriaTeste cat = new CategoriaTeste();
            cat.Id = 1;
            cat.Nome = "Categoria";

            target.AddOrRefreshAspect(cat);

            Assert.That(target.CountObjects, Is.EqualTo(1));
        }
        public void GeraInsertCategoriaTeste()
        {
            CategoriaTeste categoria = new CategoriaTeste();
            categoria.Id = 2;
            categoria.Nome = "Comidas";

            target = new CommandUpdateGenerator(categoria);

            string insert = "UPDATE categoria_teste SET nome = 'Comidas' WHERE id = 2";

            Assert.That(target.GetCommand(), Is.EqualTo(insert));
        }
        public void GeraDeleteProduto()
        {
            CategoriaTeste cat = new CategoriaTeste();
            cat.Id = 65;
            cat.Nome = "Cat Delete";

            target = new CommandDeleteGenerator(cat);

            string delete = "DELETE FROM categoria_teste WHERE id = 65";

            Assert.That(target.GetCommand(), Is.EqualTo(delete));
        }
        public void AdicionaInstanciaCategoriaTesteAoDicionario()
        {
            Assert.That(target.CountObjects, Is.EqualTo(0));

            CategoriaTeste cat = new CategoriaTeste();

            cat.Id   = 1;
            cat.Nome = "Categoria";

            target.AddOrRefreshObject(cat);

            Assert.That(target.CountObjects, Is.EqualTo(1));
        }
        public void GeraUpdateCategoriaTeste()
        {
            CategoriaTeste categoria = new CategoriaTeste();
            categoria.Id = 2;
            categoria.Nome = "Comidas";

            DictionaryEntitiesAspects.GetInstance().AddOrRefreshAspect(categoria);

            categoria.Nome = "Comidas 1";

            target = new CommandUpdateGenerator(categoria);

            string insert = "UPDATE categoria_teste SET nome = 'Comidas 1' WHERE id = 2";

            Assert.That(target.GetCommand(), Is.EqualTo(insert));
        }
        //[Test]
        public void TestA()
        {
            CategoriaTeste cat = new CategoriaTeste();
            cat.Id = 20000;
            cat.Nome = "Teste Insert";

            var insert = new CommandInsertGenerator(cat).GetCommand();

            NonQueryCommandsExecutor executor = new NonQueryCommandsExecutor(cat);
            executor.Execute();

            var novaCategoria = Joke.Query<CategoriaTeste>()
                .Where("categoriaTeste.Id = 20000")
                .Execute()[0];

            Assert.That(novaCategoria.Id, Is.EqualTo(20000));
            Assert.That(novaCategoria.Nome, Is.EqualTo("Teste Insert"));
        }
        public void AdicionaInstanciaCategoriaTesteAoDicionarioUmaUnicaVez()
        {
            Assert.That(target.CountObjects, Is.EqualTo(0));

            CategoriaTeste cat = new CategoriaTeste();
            cat.Id = 1;
            cat.Nome = "Categoria";

            target.AddOrRefreshAspect(cat);
            Assert.That(target.CountObjects, Is.EqualTo(1));
            Assert.That(cat, Is.Not.EqualTo(target.GetAspect(cat)));

            var aspecto = target.GetAspect(cat) as CategoriaTeste;
            Assert.That(cat.Id, Is.EqualTo(aspecto.Id));
            Assert.That(cat.Nome, Is.EqualTo(aspecto.Nome));

            target.AddOrRefreshAspect(cat);
            Assert.That(target.CountObjects, Is.EqualTo(1));
            Assert.That(cat, Is.Not.EqualTo(target.GetAspect(cat)));

            aspecto = target.GetAspect(cat) as CategoriaTeste;
            Assert.That(cat.Id, Is.EqualTo(aspecto.Id));
            Assert.That(cat.Nome, Is.EqualTo(aspecto.Nome));
        }