Skip to content

robhalevt/RobHaleVt.TestCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RobHaleVt.TestCore

Overview

Written before I became familiar with NUnit's Randomizer Methods, this class library helped me with the development of .NET unit tests. The focus is on extension methods that allow for easy creation of pseudo-random values. To use, create a class that has the NUnit TestFixtureAttribute on it and which inherits from the RobHale.TestCore.BaseTestFixture class. This exposes a field named Random, of type System.Random. This allowed me to assign a pseudo-random value when a test would run.

// two examples
uint quantity = Random.NextUInt(1, 50);
bool isMatch = Random.NextBool();

The implementation around getting a random Enum value, NextEnum<T>, allows for an IEnumerable<T> of Enum values to exclude from the results.

var excluded = new[] { AttributeTargets.Module, AttributeTargets.Assembly, AttributeTargets.Constructor };
var target = Random.NextEnum<AttributeTargets>(excluded);

About

Helpful methods for generating psuedo-random values for a unit test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages