Ejemplo n.º 1
0
 private void Dado_Uma_TableAdadpter_com_log_ativo_e_sem_chave()
 {
     _tableWithlog = DbTesteNampula.CreateObject <FakeTableWithLog>();
     _tableWithlog.TableAdapterLog.Detach();
     _tableWithlog.Collumns.ForEach(c => c.Key = false);
     _tableWithlog.KeyFields.Clear();
 }
Ejemplo n.º 2
0
        public void Passar_Listas_Vazias_Para_Sql_NotIn_Nao_Deve_Retornar_Nenhum_Registro()
        {
            Criar20Registros();

            var fakeTable  = DbTesteNampula.CreateObject <FakeTableForQuery>();
            var tableQuery = new TableQuery(fakeTable);

            tableQuery.Where.Add(
                new QueryParam(fakeTable.Collumns["Id"], eCondition.ecNotIn, new object[] { }));

            var resultOfConsult = _scriptWizard.GetSelectComplexStatment(tableQuery);

            Console.WriteLine("Query : \n{0}", resultOfConsult.Item1);

            Console.WriteLine("Parameters : ");

            foreach (var paramter in resultOfConsult.Item2)
            {
                Console.WriteLine("{0}:{1}", paramter.Name, paramter.Value);
            }

            var data = fakeTable.FillCollection <FakeTableForQuery>(tableQuery);

            Assert.AreEqual(20, data.Count);

            fakeTable  = DbTesteNampula.CreateObject <FakeTableForQuery>();
            tableQuery = new TableQuery(fakeTable);

            tableQuery.Where.Add(
                new QueryParam(fakeTable.Collumns["Id"], eCondition.ecNotIn, null));

            data = fakeTable.FillCollection <FakeTableForQuery>(tableQuery);

            Assert.AreEqual(20, data.Count);
        }
Ejemplo n.º 3
0
        public void Deve_Permitir_Consultar_Sql_Not_In()
        {
            Criar20Registros();
            var fakeTable  = DbTesteNampula.CreateObject <FakeTableForQuery>();
            var tableQuery = new TableQuery(fakeTable);

            tableQuery.Where.Add(
                new QueryParam(fakeTable.Collumns["Id"], eCondition.ecNotIn, new[] { 1, 2 }));

            var resultOfConsult = _scriptWizard.GetSelectComplexStatment(tableQuery);

            Console.WriteLine("Query : \n{0}", resultOfConsult.Item1);

            Console.WriteLine("Parameters : ");

            foreach (var paramter in resultOfConsult.Item2)
            {
                Console.WriteLine("{0}:{1}", paramter.Name, paramter.Value);
            }

            var data = fakeTable.FillCollection <FakeTableForQuery>(tableQuery);

            Assert.AreEqual(18, data.Count);
            Assert.AreEqual(false, data.Any(c => c.Id == 1));
            Assert.AreEqual(false, data.Any(c => c.Id == 2));
        }
Ejemplo n.º 4
0
        private void Dado_uma_tabela_com_log_ativado_criada_no_banco_dados()
        {
            _tableWithlog = DbTesteNampula.CreateObject <FakeTableWithLog>();

            Connection.Instance.DropTable(_tableWithlog.TableName);
            Connection.Instance.DropTable(_tableWithlog.TableName + "Log");

            _tableWithlog.Create();
        }
Ejemplo n.º 5
0
        private void Criar20Registros()
        {
            Connection.Instance.SqlServerExecute("DELETE FROM DbTesteNampula..FakeTableForQuery");

            foreach (var i in Enumerable.Range(1, 20))
            {
                var fakeTable = DbTesteNampula.CreateObject <FakeTableForQuery>();
                fakeTable.Id          = i;
                fakeTable.Description = "Teste " + i;
                fakeTable.Add();
            }
        }
Ejemplo n.º 6
0
        private void Dado_uma_tabela_com_log_de_2_instancias_com_data()
        {
            _tableWithlog = DbTesteNampula.CreateObject <FakeTableWithLogWithThreFields>();

            Connection.Instance.DropTable(_tableWithlog.TableName);
            Connection.Instance.DropTable(_tableWithlog.TableName + "Log");

            _tableWithlog.Create();

            AdicionarRegistro("Fábio Oliveira", DateTime.Now.AddDays(-2));
            AtualizarRegistra("Fabio Nascimento 2", DateTime.Now);

            var instances = _tableWithlog.TableAdapterLog.GetByBaseId();

            instances.Rows.Count.Should().Be.EqualTo(2);
        }
Ejemplo n.º 7
0
 public void Dado_Uma_TableAdadpter_com_log_ativo()
 {
     _tableWithlog = DbTesteNampula.CreateObject <FakeTableWithLog>();
 }
Ejemplo n.º 8
0
 private void Dado_Uma_TableAdadpter_com_log_desativado()
 {
     _tableWithlog = DbTesteNampula.CreateObject <FakeTableWithLog>();
     _tableWithlog.SetAutoLog(false);
 }