Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find bin folder when performing unit test with NUnit #26

Open
stealth6 opened this issue Apr 22, 2022 · 9 comments
Open

Could not find bin folder when performing unit test with NUnit #26

stealth6 opened this issue Apr 22, 2022 · 9 comments
Labels

Comments

@stealth6
Copy link

When using this nuget to set up autofac for unit testing it's not working. It's searching for the assemblies in the wrong (non-existant) folder.

AppDomain.CurrentDomain.BaseDirectory is already pointing to the bin folder, so adding "bin" to the end here:
var binDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin");
results in "/bin/bin" as the path when unit testing.

@quirijnslings
Copy link
Member

This will probably fix it:

var binDirectory = Path.Combine(this.GetType().Assembly.Location, "bin");

@stealth6
Copy link
Author

stealth6 commented Apr 22, 2022

Thanks I've created a PR for the change.

EDIT: didn't work will look again later.

@quirijnslings
Copy link
Member

My suggestion was wrong, the location of the Autofac assembly IS the bin folder of the web site, or the folder where the unit tests are, so this would be a better idea:

var binDirectory = this.GetType().Assembly.Location;

@stealth6
Copy link
Author

I've updated the PR. I couldn't use "this" since it's a static method. Also while testng I ran into an issue with it trying to load PDB files, so adjusted the "GetFiles" line to only retrieve .dll files.

Could you review the PR?

@stealth6
Copy link
Author

If you could also take a look at my issue in DD4T.Model dd4t/DD4T.Model#44 I also created a new PR for that.

@quirijnslings
Copy link
Member

Unfortunately this breaks if you run a website in IIS Express. I will see if I can find a solution that works in every scenario

@quirijnslings
Copy link
Member

How about this? #29
Does that work for you?

@stealth6
Copy link
Author

Looks good thanks.

@stealth6
Copy link
Author

stealth6 commented Jul 4, 2022

How about this? #29 Does that work for you?

Hello, when can we expect a new version release? Is there anything else required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants