How to fake SqlDataAdapter, SqlConnection and SqlCommand in unit tests?

As a general rule, to mock sealed classes (1) you need a mocking framework that can do it or (2) you need to write (unsealed) wrappers around the sealed class and use/mock those. TypeMock can mock sealed classes, but it costs money. But, beware, the ability to mock sealed classes and other typically non-mockable items, can keep you from having to refactor your code to a better design (assuming you agree that testable code is better code).

Wrappers or adapters are relatively easy to write, but they are themselves not testable for precisely the same reason you write them. Because of their simplicity, though, you can often reason that they are correct by inspection.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions