Setup a project for testing
Agregar > nuevo proyecto
Proyecto de prueba NUnit
Ponerle como nombre `
Esto deberia crear un proyecto nuevo con un test autogenerado
Comprobar los following Nuggets
NUnit
NUnit.Analyzers
NUnit3TestAdapter
Moq
FluentAssertions
FluentAssertions.Analyzers
Como vamos a testear el proyecto original desde el proyecto nuevo .Tests, necesitamos aƱadir una referencia al mismo desde el proyecto .Tests
click derecho en proyecto .Tests > agregar > Referencia del proyecto...
Seleccionar el proyecto a testear > aceptar
Naming conventions
Name testing projects as [ProjectUnderTest].Tests
Name testing classes as [ClassNameUnderTest]Test
Name testing functions different styles:
- start with should and write the general idea
void ShouldAddTwoNumbers
- start with the name of the function under test and _ and what should it do
void Sum_ShouldAddTwoNumbers
- UnitUnderTest_Scenario_ExpectedOutcome
ParsePort_COM1_Returns1