Click here to Skip to main content
12,999,010 members (48,161 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 1-Jan-13 20:21pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You could try using the MolesEraseStaticConstructor.
More about it here -[^].
Vijay_Gurunanee 30-Mar-13 8:35am
Sorry Friend for delay in reply!!!
but it is not helping me!!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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...

Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 19 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100