sábado, 5 de septiembre de 2015

Entrega Final de los modulos de las calculadora

(Funciones especiales por tipo numerico y pruebas unitarias)

En esta entrega se independizan las funciones especiales y se agregan a cada tipo de numeros o clase que se usa y se registran las pruebas unitarias de algunos de los metodos.
Descargar proyecto C#


Prueba de Enteros




using Calculadora;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;


namespace UnitTestProject1
{

[TestClass()]
public class EnterosTest
{
private TestContext testContextInstance;
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Atributos de prueba adicionales
#endregion
[TestMethod()]
public void EnterosConstructorTest()
{
Entero target = new Entero();
Assert.Inconclusive("TODO: Implementar código para comprobar el destino");
}
[TestMethod()]
///[ExpectedException(typeof(SystemException))]
///esta linea es para hacer pruebas con excepciones
public void RestarTest()
{
int a = 5;
int b = 3;
int expected = 2; // TODO: Inicializar en un valor adecuado
int actual;
actual = Entero.Restar(x, y);
Assert.AreEqual(expected, actual);
}
[TestMethod()]
[ExpectedException(typeof( ArgumentNullException))]
public void RestarTest()
{
int x = 5;
int y = -3;
Enteros.Restar(x, y);
}
}
}

Prueba de Imaginarios



using Calculadora;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[TestClass()]
public class ImaginarioTest
{
private TestContext testContextInstance;
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Atributos de prueba adicionales
#endregion
[TestMethod()]
public void ImaginarioConstructorTest()
{
Imaginario target = new Imaginario ();
Assert.Inconclusive("TODO: Implementar código para comprobar el destino");
}
[TestMethod()]
///[ExpectedException(typeof(SystemException))]
///esta linea es para hacer pruebas con excepciones
public void DividirTest()
{
Double a = 10;
Double b = 2;
Double expected = 5; // TODO: Inicializar en un valor adecuado
Double actual;
actual = Irracional.Multuplicar(x, y);
Assert.AreEqual(expected, actual);
}
[TestMethod()]
[ExpectedException(typeof( DivideByZeroException))]
public void MultiplicarTest()
{
Double x = 5;
Double y = 0;
Irracional.Multiplicar(x, y);
}
}
}

Prueba Irracionales



using Calculadora;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[TestClass()]
public class IrracionalTest
{
private TestContext testContextInstance;
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Atributos de prueba adicionales
#endregion
[TestMethod()]
public void IrracionalConstructorTest()
{
Irracional target = new Irracional();
Assert.Inconclusive("TODO: Implementar código para comprobar el destino");
}
[TestMethod()]
///[ExpectedException(typeof(SystemException))]
///esta linea es para hacer pruebas con excepciones
public void MultiplicarTest()
{
int a = 5;
int b = 3;
int expected = 15; // TODO: Inicializar en un valor adecuado
int actual;
actual = Irracional.Multuplicar(x, y);
Assert.AreEqual(expected, actual);
}
[TestMethod()]
[ExpectedException(typeof( ArgumentNullException))]
public void MultiplicarTest()
{
int x = 5;
int y = -3;
Irracional.Multiplicar(x, y);
}
}
}

Prueba de Naturales



using Calculadora;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace UnitTestProject1
{
[TestClass()]
public class NaturalTest
{
private TestContext testContextInstance;
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Atributos de prueba adicionales
#endregion
[TestMethod()]
public void NaturalConstructorTest()
{
Natural target = new Natural();
Assert.Inconclusive("TODO: Implementar código para comprobar el destino");
}
[TestMethod()]
///[ExpectedException(typeof(SystemException))]
///esta linea es para hacer pruebas con excepciones
public void SumarTest()
{
int a = 5;
int b = 3;
int expected = 8; // TODO: Inicializar en un valor adecuado
int actual;
actual = Natural.Sumar(x, y);
Assert.AreEqual(expected, actual);
}
[TestMethod()]
[ExpectedException(typeof(IndexOutOfRangeException))]
public void SumaNaturalTest()
{
int x = 5;
int y = -3;
Natural.Sumar(x, y);
}
}
}



No hay comentarios:

Publicar un comentario