Guest User

Untitled

a guest
Nov 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. using System;
  2. using Microsoft.VisualStudio.TestTools.UnitTesting;
  3. using DAL.Model;
  4. using DAL.Persistence;
  5.  
  6. namespace GErenciamentoTarefas_TesteUnitario
  7. {
  8. [TestClass]
  9. public class UnitTest1
  10. {
  11. TarefaDAO td = new TarefaDAO();
  12. int retorno1 = 0;
  13. int retorno2 = 0;
  14. int retorno3 = 0;
  15.  
  16. [TestMethod]
  17. public void testeIncluirTarefa()
  18. {
  19. Tarefa tarefa1 = new Tarefa();
  20. tarefa1.DataEntrega = "19/11/2018";
  21. tarefa1.Nome = "Nome em Teste";
  22. tarefa1.Responsavel = "Responsavel em Teste1";
  23. tarefa1.Tipo = "1";
  24.  
  25. Tarefa tarefa2 = new Tarefa();
  26. tarefa2.DataEntrega = "22/11/2018";
  27. tarefa2.Nome = "Nome em Teste";
  28. tarefa2.Responsavel = "Responsavel em Teste2";
  29. tarefa2.Tipo = "2";
  30.  
  31. Tarefa tarefa3 = new Tarefa();
  32. tarefa3.DataEntrega = "25/11/2018";
  33. tarefa3.Nome = "Nome em Teste";
  34. tarefa3.Responsavel = "Responsavel em Teste3";
  35. tarefa3.Tipo = "3";
  36.  
  37. retorno1 = td.Gravar(tarefa1);
  38. retorno2 = td.Gravar(tarefa2);
  39. retorno3 = td.Gravar(tarefa3);
  40.  
  41. Assert.AreEqual(0, retorno1);
  42. Assert.AreEqual(0, retorno2);
  43. Assert.AreEqual(0, retorno3);
  44. }
  45.  
  46. }
  47. }
  48.  
  49. using System;
  50. using System.Collections.Generic;
  51. using System.Linq;
  52. using System.Text;
  53. using System.Threading.Tasks;
  54. using System.Data.OleDb;
  55. using System.Data;
  56. using System.Configuration;
  57.  
  58. namespace DAL.Persistence
  59. {
  60. public class ConexaoAccess
  61. {
  62.  
  63. protected OleDbConnection Con;
  64. protected OleDbCommand Cmd;
  65. protected OleDbDataAdapter Da;
  66.  
  67. protected void AbrirConexao()
  68. {
  69. try
  70. {
  71. //Busca a string de conexão com o banco no arquivo Web.config
  72. Con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conexaoBanco"].ConnectionString);
  73. Con.Open();
  74. }
  75. catch (Exception ex)
  76. {
  77. throw new Exception("Erro ao abrir conexão com banco de dados: " + ex.Message);
  78. }
  79.  
  80. }
  81.  
  82. protected void FecharConexao()
  83. {
  84. try
  85. {
  86. Con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conexaoBanco"].ConnectionString);
  87. Con.Close();
  88. }
  89. catch (Exception ex)
  90. {
  91. throw new Exception("Erro ao fechar conexão com banco de dados: " + ex.Message);
  92. }
  93. }
  94.  
  95.  
  96.  
  97. }
  98. }
  99.  
  100. protected OleDbConnection Con = new OleDbConnection(ConfigurationManager.ConnectionStrings["conexaoBanco"].ConnectionString);
  101. protected OleDbCommand Cmd;
  102. protected OleDbDataAdapter Da;
Add Comment
Please, Sign In to add comment