Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6747443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:26:34+00:00 2026-05-26T12:26:34+00:00

I have a solution with multiple projects and one of these projects is my

  • 0

I have a solution with multiple projects and one of these projects is my service class which calls into the persistence manager.

I would like to write a unit test as follows:

 [Test]
    public void Create_HappyPath_Success()
    {
        // Arrange
        UnitOfMeasure unitOfMeasure = new UnitOfMeasure();
        unitOfMeasure.Code = "Some new unit of measure";
        unitOfMeasure.DataOwner = 1;

        // Act
        this.UoMService.Create(unitOfMeasure);  // Fails here as UoMService is null

        // Assert something

    }

Now, I’m getting a null reference exception on this line:

 this.UoMService.Create(unitOfMeasure);  // Fails here as UoMService is null

I believe that it’s due to the fact that Castle Windsor is not getting called and hence the UoMService isn’t getting instantiated. My Castle Windsor application installer is defined in another project i.e. my ASP.NET MVC project. So my first question is whether it’s possible to reuse that installer to run my Unit Tests.

Now to get around this problem, I created a new installer in my unit test project by linking to the installer in my web project. Then I used the following code in my set up:

  [SetUp]
    public void ControllersInstallerTests()
    {
        this.containerWithControllers = new WindsorContainer();
        IoC.Initialize(this.containerWithControllers);

        this.containerWithControllers.Install(FromAssembly.This());
    }

This time when I run the tests, I get the following error:

SetUp : Castle.Windsor.Configuration.Interpreters.XmlProcessor.ConfigurationProcessingException : Error processing node resource FileResource: [] []
—-> Castle.Core.Resource.ResourceException : File C:\Projects\DavidPM\Services\MyProject.Services.ServiceImpl.Test.Unit\bin\Debug\Config\Windsor.config could not be found

The question is why is it looking in the bin\Debug folder?

As a newbie with Castle Windsor, I am not sure what I should be doing to hook into Castle Windsor for my unit tests.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:26:34+00:00Added an answer on May 26, 2026 at 12:26 pm

    You should not be hooking up your IoC container in your unit tests. During production, your IoC container will resolve dependencies. During unit tests, you create the dependencies as part of your tests — usually using a mocking framework so you can test in isolation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution in Visual Studio 2008 which has multiple projects. One of
my solution has multiple projects and in one of them I have the code
I have a solution which has multiple output projects (a website, and admin tool,
I would like to have a file in several different projects of a solution,
I have a solution with multiple projects and we need to do some serious
If I have an existing solution containing multiple c# projects, are there any static
I have a visual studio 2008 solution with multiple c# library projects, a Web
Many times I have seen Visual Studio solutions which have multiple projects that share
I have a solution with several projects. One of them is a setup project.
I have a solution with many projects. One project contain few custom components. One

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.