I am new at unit testing:
I have a pretty simple class, below (mysite.cs).
public class MySite : IComparable
{
[XmlAttribute]
public Guid Id { get; set; }
[XmlAttribute]
public string Url { get; set; }
[XmlAttribute]
public string Title { get; set; }
override public string ToString()
{
return Title;
}
Following is my test method, which runs successfully when I would expect it to fail, given the title is different then the expectation of the tostring method, even though the overridden tostirng method just returns the title property.
[Isolated]
[Test]
public void TestMethod1()
{
//Arrange
MySite fake = Isolate.Fake.Instance<MySite>(Members.ReturnRecursiveFakes);
fake.Title = "123";
Isolate.WhenCalled(() => fake.ToString()).WillReturn("Test 123");
//Act
fake.ToString();
//Assert
Isolate.Verify.WasCalledWithAnyArguments(() => fake.ToString());
}