I'm currently trying to work myself into unit testing for my firm, who before have never worked with that conecpt. I've previously written a program that accepts customer IDs and reads the corresponding data (name of the firm, address, etc.) from our iDB2 database and displays it in the UI. Here I want to implement a unit test that, if I input a certain customer ID, expects a certain customer name as output.
The test unfortunately fails, even though it shouldn't. When I try debugging the test it throws the following exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Das System kann die angegebene Datei nicht finden.
The unit test looks as follows:
using Kundeninformationen;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace KDNAbrufTest
{
[TestClass]
public class UnitTest1
{
int input = **customerID**;
public int Aufruf(int input)
{
Methoden.AufrufKundenname(input);
return input;
}
[TestMethod]
public void TestMethod1()
{
string expected = "**customer name**";
string result = Methoden.AufrufKundenname(input);
Assert.AreEqual(expected, result);
}
}
}
The method AufrufKundenname connects to the database in another class by using an iDB2Connection, iDB2Command and iDB2DataAdapter. In the program itself there is no problem with connection to the database but I might have overlooked something I would have needed to implement in my test class.
I've gone through a lot of posts of people having similar problems being solved by adding an AppConfig file to the test folder but unfortunately that didn't solve it for me.
I myself am neither expert of unit testing nor an advanced C# programmer nor is English my first language so please excuse any unclear phrasing and beginner's mistakes.