2
I just installed in my project the "Nunit" for unit testing.
Installed via Nuget, on the VS2013 console.
I put the notes on top of my methods I went on Explorer test and gave a "Run ALL".
This "Run ALL" is just compiling my project and not showing me which tests
passed and failed.
NOTE: My project was already ready.
My code
using NUnit.Framework;
[TestFixture]
public class LogDAO
{
/// <summary>
/// Metodo para inclusão
/// </summary>
/// <param name="UserID"></param>
/// <param name="Acao"></param>
/// <returns></returns>
[Test]
public void InserirLog(string UserID, string Acao)
{
using (entidadesIUS entidades = new entidadesIUS())
{
LogUtilizacaoIUS log = new LogUtilizacaoIUS();
log.UserId = new Guid(UserID);
log.Acao = Acao;
log.DataOcorrencia = DateTime.Now;
entidades.LogUtilizacaoIUS.Add(log);
entidades.SaveChanges();
}
}
}
My Explorer test only looks like this as I’ve already said.
Only an addendum, when you "touch" the database, is no longer a unit test but an integration test. It is less clear that save changes is a "mock". http://artofunittesting.com/definition-of-a-unit-test/
– BrenoSarkis