I am a beginner to C# and I am getting this error Argument 1: Cannot convert from 'string' to 'System.Action'
. I honestly do not know how to fix this. if you could help me please tell me what I should add to my code to fix this error. I am basically writing a Unit Test that will test if the code is working correctly (the code is supposed to throw an exception). This is my code:
Unit Test Project File:
[TestMethod]
public void ExceptionTest()
{
var test = new JumpingCode();
Assert.ThrowsException<ArgumentException>(test.EmptyValue(null));
}
The Class File:
namespace Jumping
{
public class JumpingCode
{
public string EmptyValue(string some)
{
if (string.IsNullOrEmpty(some))
{
throw new ArgumentException("Name Cannot be null or empty");
}
return "Hello World";
}
}
}
I am basically testing a random throw. The Unit Test file is the one throwing the error messages. The error messages are on this line Assert.ThrowsException<ArgumentException>(test.EmptyValue(null))
the test.EmptyValue(null)
is the text that is underlined. I honestly have no idea what is the problem. I know I am doing something wrong but I just don't know what. I don't know if this will change anything but I have never wrote a unit test for an exception before.