Created
December 8, 2010 12:36
-
-
Save tucaz/733230 to your computer and use it in GitHub Desktop.
Generates one test method for each entry of external data using NUnit test framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NUnit.Framework; | |
namespace NUnitDataDriven | |
{ | |
[TestFixture] | |
public class DataTests | |
{ | |
[Test, TestCaseSource("GetDataForTesting")] | |
public void age_should_be_over_18(Data data) | |
{ | |
Assert.IsTrue( | |
IsAgeOver18(data.Age) | |
); | |
} | |
private bool IsAgeOver18(int age) | |
{ | |
return age > 18; | |
} | |
private Data[] GetDataForTesting() | |
{ | |
return new Data[3] { new Data() { Age = 20 }, new Data() { Age = 22 }, new Data() { Age = 17 } }; | |
} | |
} | |
public struct Data | |
{ | |
public string Name { get; set; } | |
public int Age { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vlw! Ajudou bastante!