Refactor Code

  • Gravatar
    Unit Testing Castle Active Record Initialization

    by azamsharp on 5/11/2008 7:11:21 PM
  • I have some static code that is used to initialize the Active Record framework. That particular code should be executed once hence I have placed it inside the static constructor of the BaseTest class. All the test classes inherits from the BaseTest class. Now, the question is how should I test the static code that is used to initialize the active record framework. Ohh yeah the appconfig.xml file is an embedded resource. I am able to test the static code by creating the object of the BaseTest class inside the unit test but is there a better way!
  • static BaseTest()
    {
    string resourceName = "TestSuite.appconfig.xml";
    Assembly ass = Assembly.Load("TestSuite");
    XmlConfigurationSource config = new XmlConfigurationSource(ass.GetManifestResourceStream(resourceName));
    Assembly a = Assembly.Load("DomainObjects");
    ActiveRecordStarter.Initialize(a, config);
    }

    [Test]
    public void can_initialize_active_record_framework()
    {
    BaseTest b = new BaseTest();
    }




  • Refactor it!
Please log in to refactor the code! Login