How to add an assembly reference in unit test project?

5.1k Views Asked by At

I want to add a reference to an assembly in my unit test project, because it has to be referenced in order to call the method to be tested, but... I can't. I don't have the option to do so in the "Add reference" window in Visual Studio. I can only add Project references or Browse for dll references (see image below, left is unit test project and right is the app project's "Add reference" window)

Unit test project add reference window Main app add reference window

I have the error "The type is defined in an assembly that is not referenced. You must add a reference to the assembly.", but when I go ahead and use the quick action to do so, nothing happens.

Why can't I add a reference to the assembly and is there another way around the missing assembly issue?

Note: Using Visual Studio 2017

1

There are 1 best solutions below

0
On BEST ANSWER

Following the discussion with @Dai, the assembly references weren't available because an NUnit Test Project created in Visual Studio is created using .NET Core rather than .NET Framework.

To have access to .NET Framework assemblies, you need to create a .NET Framework Unit Test Project and then replace the MS Test Framework with the NUnit Test Framework.