Effect, change of state

State change is a secondary effect generated by executing a unit of code.
To validate the result we must access the state that has changed, so it is compromised of three steps:
- Execute the unit of code
- Access the changed state
- Verify the value is as expected
/** State that is changed */
let currentValue = 0;
/** Unit of code that has an effect.
* It changes currentValue
*/
function add(summand: number): void {
/**
* Exit point => Effect, Change of state
*/
currentValue += summand;
}
/**
* Way to access current state
*/
function getCurrentValue(): number {
return currentValue;
}
/** Execute unit of code */
sumar(5);
/** Access changed state */
const valorAcumulado = obtenerValorActual();
/** Verify obtained value is what we expect */
valorAcumulado === 5;






