.net - How to run the same testmethods while only changing the dependencies? -


I have 5 testmethods that test the functionality of PasswordManager object. I use a test engine built on Visual Studio 2008. The manager can use two dependencies: an XMLStorageManager or a DbStorageManager. Dependency is set in the manufacturer of PasswordManager What type of storage manager can I use?

(I know, I know these units are not tested ...)

I'm not an MSTist user, but you probably have some options. Normally I use a normal or parametric stability with NUnit, but I'm not sure whether MSTE has the same capabilities. In light of this, here's how I will do it with NUINT, through which any unit should be reproducible using the test framework.

Step:

  • Define
  • Create an estostate method that includes the CrystAst Manager () which gives an isorriage manager (or which Two dependencies apply)
  • The subclass provides twice the implementation of CreateStorageManager () and gives the concrete type that you want to use to run the test.

Here is the code for the same NUNIT version; I'm sure you can extrapolate. Note: Some of the succession rules for MST can be different which I do. If this does not work, you can try to mark the base class as a test fist.

  Public Intangible Class PasswordManagerFixtureBase {Protected summary Istorage Manager CreateStorageManager (); // test all in this persistence [test] Public Zero SomeTestOrOther () {var Password Manager = CreatePasswordManager (); // do test logic} Private Password Manager CreatePasswordManager () {// Storage for example obtaining an instance in the subcategory implementation IStorageManager storage = CreateStorageManager (); New password manager return (storage); }} // XmlStorageManager [TestFixture] runs a test in the fixture base using the public class PasswordManager_XMLStorageManagerImplTests {secure override estimate manager CreateStorageManager () {new XMLStorageManager (); }} // DbStorageManager [TestFixture] runs a test in the fixture base using the public class PasswordManager_DbStorageManagerImplTests {Secure Override Estherage Manager CreateStorageManager () {Return New DbStorageManager}; }}  

There may be another great way to do this with MSTE, but it should work.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -