C
C#7mo ago
SirTankie

Problem using class libraries in Unit tests

For a school project I need to use Unit tests in my project, however when I add the unit test project, I can not use the classes from a different class library. I have set up the dependencies, so I dont know what I should do.
19 Replies
Pobiega
Pobiega7mo ago
show your solution structure and the dependencies for the test lib
SirTankie
SirTankieOP7mo ago
No description
SirTankie
SirTankieOP7mo ago
No description
Pobiega
Pobiega7mo ago
No description
Pobiega
Pobiega7mo ago
I would suggest you structure it like this instead
SirTankie
SirTankieOP7mo ago
do you mean in a different solution?
Pobiega
Pobiega7mo ago
no, same solution in terms of actual file structure on disk, it would be...
.
├── MyProj.sln
├── .gitignore
├── .editorconfig
├── src/
│ ├── MyProj.Administration
│ ├── MyProj.AccessLayer
│ ├── MyProj.LogicLayer
│ └── MyProj.WebPagesLeaderboards
└── tests/
├── MyProj.Administration.Tests
├── MyProj.AccessLayer.Tests
├── MyProj.LogicLayer.Tests
└── MyProj.WebPagesLeaderboards.Tests
.
├── MyProj.sln
├── .gitignore
├── .editorconfig
├── src/
│ ├── MyProj.Administration
│ ├── MyProj.AccessLayer
│ ├── MyProj.LogicLayer
│ └── MyProj.WebPagesLeaderboards
└── tests/
├── MyProj.Administration.Tests
├── MyProj.AccessLayer.Tests
├── MyProj.LogicLayer.Tests
└── MyProj.WebPagesLeaderboards.Tests
SirTankie
SirTankieOP7mo ago
Ok I will try to do this
Pobiega
Pobiega7mo ago
however, you shouldnt be having the problems you say you are so there is something wrong what .NET version are you using? Is it the same for test project and class libs?
SirTankie
SirTankieOP7mo ago
i think 8.0
No description
SirTankie
SirTankieOP7mo ago
but here it says 4.8
No description
SirTankie
SirTankieOP7mo ago
but when i try to change it, i can not select 8.0
Pobiega
Pobiega7mo ago
yeah thats your problem .NET Framework isnt the same thing as just .NET you need to delete your test project and create it from scratch with a .NET version, not a framework version I highly recommend using xUnit $newproject
MODiX
MODiX7mo ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
SirTankie
SirTankieOP7mo ago
so this one is fine?
No description
Pobiega
Pobiega7mo ago
No description
Pobiega
Pobiega7mo ago
again, I highly recommend xunit it has the most logical way of working, imho
SirTankie
SirTankieOP7mo ago
YESSS IT WORKSS thank youuu
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server