Reputation: 53
I need help on writing a unit test for this
Public static Boolean InList(byte value, Type t)
{
if (!Enum.IsDefined(t, value))
{
return false;
}
return true;
}
This is what i written so far but it keep given me error "out of bound"
[TestMethod()]
Public void InListTest()
{
Assert.IsTrue(ValidationUI.InList(1, Type.EmptyTypes[0]));
}
I don't expect what I wrote on unit test is what the test is asking for, i need some guidance. Thanks in advance
Upvotes: 0
Views: 10780
Reputation: 73243
This will test your method:
public enum TestEnum : byte {
One = 1,
Two = 2
}
[TestMethod()]
Public void InListTest()
{
Assert.IsTrue(ValidationUI.InList(1, typeof(TestEnum));
Assert.IsFalse(ValidationUI.InList(100, typeof(TestEnum));
}
Upvotes: 1