Using Castle Windsor in Unit Test Class
<p>I'm a noob with Castle Windsor. I'm building an application that uses Entity Framework 6 and Castle Windsor, with an MSTest Unit Test class. My application has a class in it that implements <code>IWindsorInstaller</code>. My unit test class looks like this:</p>

<pre><code>[TestClass]
public class DatabaseTests {

    static readonly WindsorContainer Container = new WindsorContainer();

    public DatabaseTests() {
        Container.Install( FromAssembly.This() );
    }

    [TestMethod]
    public void FirstTest() {
        // Test statements
    }

    [TestMethod]
    public void SecondTest() {
        // Test statements
    }

    // Other tests
}
</code></pre>

<p>There is also an installer class in the unit tests project that looks like this:</p>

<pre><code>public class TestsInstaller : IWindsorInstaller {
    public void Install( IWindsorContainer container, IConfigurationStore store ) {
        container.Install( new RecipeManager.RepositoriesInstaller() );
    }
}
</code></pre>

<p>When I go to the Unit Test Session window &amp; try to run all tests, the first one succeeds, and I get this stack trace for the rest:</p>

<blockquote>
  <p>Unable to create instance of class UnitTests.DatabaseTests. Error: Castle.MicroKernel.ComponentRegistrationException: Component RecipeManager.DAL.CategoryRepository could not be registered. There is already a component with that name. Did you want to modify the existing component instead? If not, make sure you specify a unique name..
      at Castle.MicroKernel.SubSystems.Naming.DefaultNamingSubSystem.Register(IHandler handler)
     at Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model)
     at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations)
     at Castle.Windsor.WindsorContainer.Register(IRegistration[] registrations)
     at RecipeManager.RepositoriesInstaller.Install(IWindsorContainer container, IConfigurationStore store) in C:\Users\Tony\documents\visual studio 2015\Projects\RecipeManager\ManageRecipes\RepositoriesInstaller.cs:line 10
     at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope)
     at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers)
     at UnitTests.TestsInstaller.Install(IWindsorContainer container, IConfigurationStore store) in C:\Users\Tony\documents\visual studio 2015\Projects\RecipeManager\UnitTests\TestsInstaller.cs:line 8
     at Castle.Windsor.Installer.AssemblyInstaller.Install(IWindsorContainer container, IConfigurationStore store)
     at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers, DefaultComponentInstaller scope)
     at Castle.Windsor.WindsorContainer.Install(IWindsorInstaller[] installers)
     at UnitTests.DatabaseTests..ctor() in C:\Users\Tony\documents\visual studio 2015\Projects\RecipeManager\UnitTests\DatabaseTests.cs:line 17</p>
</blockquote>

<p>If I run the unit tests one at a time, they all succeed. I intend to build lots of tests, so I'd really rather be able to run them all at once.  How do I fix this?</p>