darma teja

darma teja

  • NA
  • 496
  • 337.4k

unit test for the following code

Oct 10 2017 2:36 AM
  1. public static class myValidationExt  
  2.     {  
  3. public static IRuleBuilderOptions onlyPositive(this IRuleBuilder ruleBuilder)  
  4.             where TProperty : struct, IComparable, IComparable  
  5.         {  
  6.             return ruleBuilder.GreaterThan(default(TProperty)).WithMessage("StudentId should only be greater than zero");  
  7.         }  
  8.        }  
  1. [Test]  
  2. [ExpectedException(typeof(Exception), ExpectedMessage = "StudentId should only be greater than zero")]  
  3.  public void Positive_Valuelessthanzero_ValidationPassed()  
  4.  {  
  5.     //Arrange  
  6.     Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");   
  7.   
  8.     //Act  
  9.     var myString = myValidationExt.onlyPositive(*******); // How to pass the parameter???  
  10.   
  11.     //Assert  
  12.               

Answers (1)