c# - How do I unit test this custom commandlet -


i unable figure out how unit test if commandlet fail, if no arguments provided it.

[cmdlet(verbscommon.move, "someresource")] public class movesomeresource : cmdlet { private int _id;  [parameter(position = 0, mandatory = true)] [validatenotnullorempty] public int id  {     { return _id; }     set { _id = value; } }  protected override void processrecord() {      string text = string.format("move resource {0} ", this._id);     //do     if (shouldprocess(text, action))     {         //do processing     } } } 

i tried following method but, not fails due validatenotnullorempty error rather executes part in //do processing , fails there .

[testmethod] public void testmovebluh() { movesomeresource cmd = new movesomeresource(); ienumerator result = cmd.invoke().getenumerator(); try {     result.movenext(); } catch (exception e) {     assert.isinstanceoftype(e, typeof(argumentexception)); } } 

ok, think see issue. parameter int, int's aren't null, , never empty. suggest validating value of parameter not zero, or make int? or nullable


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -