Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
In order to remove external dependency for testing purpose i was trying to implement the mole framework

everything was working fine until i have moled the class with static readonly property.

Creating mole of that class is not the root cause of issue but that readonly property is creating the issue

in my actual method that readonly property is used and value of that property is coming null after creating mole instance
since there is not setter, getter for this property so mole class is not giving override for this property

However without mole testcase is not giving error and fetching the data from external sources

Please suggest how to proceed in this case

Thanks in advance
Posted

You could try using the MolesEraseStaticConstructor.
More about it here - http://research.microsoft.com/en-us/projects/pex/molesmanual.pdf[^].
 
Share this answer
 
Comments
Vijay_Gurunanee 30-Mar-13 8:35am    
Sorry Friend for delay in reply!!!
but it is not helping me!!!
Sorry for late reply...

but not working for me....
I just re factored the code and changed my code such that it can be moled.

But still i didn't find proper solution for this problem...

Thanks...
 
Share this answer
 
I have gone for many articles and discussions but did not found any perfect solutions.
So for now considering that it is not possible to override the private read only static properties of a sealed class. (Yes in my case, class sealed...)

So i have decided to change the design of class and then pain was gone.

Thanks for your help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900