c# - Reference type not passed as reference -


I have this strange problem in my unit testing. See the following code

  _pos = null; Utilities.Inter POS (_pos, trans); Assert.IsNotNull (_pos); // disables  

InitPOS functions

  public static zero InitPOS (POSimplementation pos, Transaction newTransaction) {Pos = new POSimplementation (); Pos.SomeProp = New SomeProp (); Pos.SomeProp.SetTransaction (newTransaction); Assert.IsNotNull (POS); Assert.IsNotNull (pos.SomeProp); }  

Object POSimplementation is the implementation of some interface and it is a class, so this is a reference type ...

Anyone idea?

You can InitPOS (i.e. a null reference ), The name of the named variable is not the reference _pos effect is that the new POSimplementation example is in local variable pos in InitPOS Method, but the _pos variable remains unchanged.

Change your code

  _pos = utilities.InitPOS (trans); Assert.IsNotNull (_pos);  

Where

  public static POSimplementation InitPOS (new conversion conversion) {POSimplementation pos = new POSimplementation (); // ... return status; }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -