Basically, I have a unit test that gets a singleton instance of a class. Some of my tests required me to mock this singleton, so when I do Foo.Instance I get a different type of instance.
The problem is that my checks are passing individually, but failing overall because one test is interfering with another.
I tried to do a TestCleanup where I set: Foo_Accessor._instance = null;
but that didn't work. What I really need is Foo_Accessor._instance.IsValueCreated 开发者_如何学C= false;
(_instance is a Lazy).
Any way to unset the Lazy object that I didn't think of?
Why not do: Foo_Accessor._instance = new Lazy<Foo>(Something);
Make sure the "Something" is exactly the same as what your Foo class is doing.
精彩评论