I try to write an unit tests. Now, I compare two values - actual and expected.
Actual value is a string and expected is a intiger, that will represent the length of actual string.
I used the Assert.AreEqual function to compare these values, but I get an error message:
Error Message:
Test method UnitBL0001.CommonTest.DecodeTest threw exception:
System.FormatException: Invalid length for a Base-64 char array.
Error Stack Trace:
System.Convert.FromBase64String(String s).
How can I comapre these values in some other way? Is my way to create unit tests is correct?
Source:
[TestMethod()]
public void DecodeTest()
{
string strCryptoPassword = "123pass"; // TODO: Initialize to an appropriate value
int expected = 0; // TODO: Initialize to an appropriate value
string actual;
actual = Common.Decode(strCryptoPassword);
expected = actual.Length;
Assert.AreEqual(expected, actual.Length);
}
Error message in unit testing
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Suthish NairRank #92 · 22.8K reputationPosted Mar 3, 2011, 7:30 AM EST
Raja KrishnamurthyRank #3,615 · 403 reputationPosted Mar 3, 2011, 8:16 AM EST
HTH