vendredi 6 février 2015

Issues trying to unit test a C# console application

I am trying to unit test a C# console application and I can test some parts of my code, and other parts I cannot test for some reason. In my unit test project I have referenced the project I am wanting to test, and have put the "using" statement in. I can create new objects from the app I am wanting to test, but cannot call any other methods.


For example, in my console application, I have a method to print out a menu:



public static void Menu()
{
Console.WriteLine("VM");
Console.WriteLine("=====");
Console.WriteLine("(a) " + _pepsi.Name + " --- $" + _pepsi.Price + " " + _pepsi.outOfStock(_pepsiList));
Console.WriteLine("(b) " + _coke.Name + " --- $" + _coke.Price + " " + _coke.outOfStock(_cokeList));
Console.WriteLine("(c) " + _redBull.Name + " - $" + _redBull.Price + " " + _redBull.outOfStock(_redBullList));
Console.WriteLine("(d) " + _monster.Name + "- $" + _monster.Price + " " + _monster.outOfStock(_monsterList));
Console.WriteLine("(e) " + _water.Name + " - $" + _water.Price + " " + _water.outOfStock(_waterList) + "\n");
}


And in my test project I would like to call it but it will not work. It says "The name 'Menu' does not exist in the current context. Any help would be appreciated. I am new to unit testing and it is a bit confusing to me.


Aucun commentaire:

Enregistrer un commentaire