Why is this passing Assert.AreSame()
?
[TestMethod]
public void StringSameTest()
{
string a = "Hello";
string b = "Hello";
Assert.AreSame(a, b);
}
I understand ìt tests for reference equality, and is essentially the same as Assert.IsTrue(object.ReferenceEquals(a, b))
but it's clear that a
and b
are different string objects, regardless of them having the same values. If Ì set string b = a;
I'd expect true, but that's not the case. Why isn't this test failing?
Thanks