Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using DAL.Model;
- using DAL.Persistence;
- namespace GErenciamentoTarefas_TesteUnitario
- {
- [TestClass]
- public class UnitTest1
- {
- TarefaDAO td = new TarefaDAO();
- int retorno1 = 0;
- int retorno2 = 0;
- int retorno3 = 0;
- [TestMethod]
- public void testeIncluirTarefa()
- {
- Tarefa tarefa1 = new Tarefa();
- tarefa1.DataEntrega = "19/11/2018";
- tarefa1.Nome = "Nome em Teste";
- tarefa1.Responsavel = "Responsavel em Teste1";
- tarefa1.Tipo = "1";
- Tarefa tarefa2 = new Tarefa();
- tarefa2.DataEntrega = "22/11/2018";
- tarefa2.Nome = "Nome em Teste";
- tarefa2.Responsavel = "Responsavel em Teste2";
- tarefa2.Tipo = "2";
- Tarefa tarefa3 = new Tarefa();
- tarefa3.DataEntrega = "25/11/2018";
- tarefa3.Nome = "Nome em Teste";
- tarefa3.Responsavel = "Responsavel em Teste3";
- tarefa3.Tipo = "3";
- retorno1 = td.Gravar(tarefa1);
- retorno2 = td.Gravar(tarefa2);
- retorno3 = td.Gravar(tarefa3);
- Assert.AreEqual(0, retorno1);
- Assert.AreEqual(0, retorno2);
- Assert.AreEqual(0, retorno3);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.OleDb;
- using System.Data;
- using System.Configuration;
- namespace DAL.Persistence
- {
- public class ConexaoAccess
- {
- protected OleDbConnection Con;
- protected OleDbCommand Cmd;
- protected OleDbDataAdapter Da;
- protected void AbrirConexao()
- {
- try
- {
- //Busca a string de conexão com o banco no arquivo Web.config
- Con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conexaoBanco"].ConnectionString);
- Con.Open();
- }
- catch (Exception ex)
- {
- throw new Exception("Erro ao abrir conexão com banco de dados: " + ex.Message);
- }
- }
- protected void FecharConexao()
- {
- try
- {
- Con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conexaoBanco"].ConnectionString);
- Con.Close();
- }
- catch (Exception ex)
- {
- throw new Exception("Erro ao fechar conexão com banco de dados: " + ex.Message);
- }
- }
- }
- }
- protected OleDbConnection Con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conexaoBanco"].ConnectionString);
- protected OleDbCommand Cmd;
- protected OleDbDataAdapter Da;
Add Comment
Please, Sign In to add comment