c# - Verifying a reference property in moq (NUnit) -


i started using moq unit tests. wanna this: test "execute" method of class a. method accepts ia type object , sets simple property in it.

[testfixture] public class {     public void execute(object s)     {         if (s ia)         {             (s ia).asimplestringproperty = "mocktestvalue";         }     } }  public interface ia {     string asimplestringproperty { get; set; } } 

i wrote unit test this:

but not work test method below: ideas going wrong?

[test] public void testmethod1() {     var person = new mock<ia>();     var = new a();     a.execute(person.object);     person.verifyset(asimplestringproperty = "mockytestvalue", "failedtest"); } 

(i want check if asimplestringproperty "mocktestvalue" couldn't reasons. also, when put debugging, see asimplestringproperty null!

you have typo in value assigning property - mockytestvalue instead of mocktestvalue. use verifyset check if property set:

person.verifyset(ia => ia.asimplestringproperty = "mocktestvalue", "failedtest"); 

btw why a class marked testfixture?


Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

How to mention the localhost in android -

php - Calling a template part from a post -