Created
May 27, 2012 13:58
-
-
Save camiloribeiro/2814321 to your computer and use it in GitHub Desktop.
Example of implementation of DDT on TDD on C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Namespaces usados | |
// Used namespaces | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using WebApplication1; | |
// Nossa classe de testes | |
// Our test class | |
[TestClass] | |
public class TrianguloTeste | |
{ | |
// Adaptação realizada para utilizar o Data Source no TestContext | |
// Adaptation made to use the Data Source in TestContext | |
private TestContext testContextInstancia; | |
public TestContext TestContext | |
{ | |
get { | |
return testContextInstancia; | |
} | |
set { | |
testContextInstancia = value; | |
} | |
} | |
// Referência usada para especificar forma de acesso do DataSource, localização, metodo, string de conexão e item usado. | |
// Reference used to specify how to access the DataSource, location, method, and connection string used item. | |
[DataSource("System.Data.Odbc", | |
"Dsn=Excel Files;dbq=|DataDirectory|\\testeDadosTriangulo.xlsx;defaultdir=C:;driverid=1046;maxbuffersize=2048;pagetimeout=5", | |
"Plan1$", | |
DataAccessMethod.Sequential), | |
DeploymentItem("TestProject1\\testeDadosTriangulo.xlsx"), | |
TestMethod] | |
// Nosso metodo de teste | |
// Our test method | |
public void validaTriangulo() | |
{ | |
// Declaração do objeto que será testado | |
// Declaration of the object to be tested | |
Triangulo triangulo = new Triangulo(); | |
// Dados de entrada | |
// Input data | |
int lado1 = int.Parse(TestContext.DataRow["lado1"].ToString()); | |
int lado2 = int.Parse(TestContext.DataRow["lado2"].ToString()); | |
int lado3 = int.Parse(TestContext.DataRow["lado3"].ToString()); | |
// Resultado esperado | |
// Expected result | |
string resultado = TestContext.DataRow["resultado"].ToString(); | |
// Comparação | |
// Test | |
Assert.AreEqual(resultado, triangulo.retornaTipoTriangulo(lado1, lado2, lado3)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment