Created
October 1, 2014 10:23
-
-
Save Imater/474aabda872be40e3945 to your computer and use it in GitHub Desktop.
test for cases in c#
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 System; | |
using Ksnsi.Services.Validation.ColValidators; | |
using NUnit.Framework; | |
namespace Ksnsi.Services.Tests | |
{ | |
[TestFixture] | |
internal class ColValidatorNumericTest | |
{ | |
private IColValidator _validator; | |
public TestCaseData[] TestValidationTestCases() | |
{ | |
return new[] | |
{ | |
new TestCaseData("5,35", 1, 2).Returns(5.35), | |
new TestCaseData("5", 1, 2).Returns(5), | |
new TestCaseData("5.55", 1, 2).Returns(5.55), | |
new TestCaseData(" 5.55 ", 1, 2).Returns(5.55), | |
new TestCaseData("0", 1, 2).Returns(0), | |
new TestCaseData(".1", 1, 2).Returns(0.1), | |
new TestCaseData("0.0", 1, 2).Returns(0), | |
new TestCaseData(".0", 1, 2).Returns(0), | |
new TestCaseData("", 1, 2).Returns(null), | |
new TestCaseData(null, 1, 2).Returns(null), | |
new TestCaseData("4-8", 1, 2).Returns(null), | |
new TestCaseData("word", 1, 2).Returns(null) | |
}; | |
} | |
[TestFixtureSetUp] | |
public void SetUp() | |
{ | |
var autoSelectValidator = new AutoSelectValidator(); | |
_validator = autoSelectValidator.GetValidator("Numeric"); | |
} | |
[Test] | |
[TestCaseSource("TestValidationTestCases")] | |
public object NumericTest(string paramValue, int columnIndex, int rowIndex) | |
{ | |
ColValidationResult colValidationResult = _validator.Validate(paramValue, columnIndex, rowIndex); | |
return colValidationResult.Value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment