2
Answers

Error message in unit testing

Ana Ana

Ana Ana

13y
1.8k
1
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);
         
        }

Attachment: source.zip

Answers (2)