C# Unrecognized Guid Format using string

  Kiến thức lập trình

I am writing some NUnit tests to verify that my program is correctly parsing the Guid from my files, so I have a static expected Guid I want to use to compare my actual result against. I populate myExpectedItem in my OneTimeSetUp.

myExpectedItem.RunID = new Guid("21810813-7e96-4d9b-bce4-8a0058a42c4a");

However, this exception is thrown when I try to run my tests.

OneTimeSetUp: System.FormatException : Unrecognized Guid format.

From what I’ve read on the Guid documentation, my string seems like it should work. I also found out that it works fine if my passed in string is all zeroes.

myExpectedItem.RunID = new Guid("00000000-0000-0000-0000-000000000000");

I’ve tried removing the hyphens, making it all uppercase, but none of those seem to work. My files are also named with the Guid, and passing the file name into new Guid() worked in the program I am testing, but the same thing is not working in my tests.

New contributor

MM1 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT