I'm trying to get FakeItEasy 1.25.3 to throw an exception on a property; the setter test works fine but the getter does not throw an exception as expected. What am I doing wrong?
public interface IMisc
{
int IntProperty { get; set; }
}
// Setter throws exception as expected.
[Test]
public void Property_Setter_Throws()
{
var driver = A.Fake<IMisc>();
A.CallTo(driver).Where(call => call.Method.Name == "set_IntProperty")
.Throws(new Exception());
var i = driver.IntProperty;
Assert.That( delegate { driver.IntProperty = 3; }, Throws.Exception);
}
// Getter does not throw exception as expected.
[Test]
public void Property_Getter_Throws()
{
var driver = A.Fake<IMisc>();
A.CallTo(driver).Where(call => call.Method.Name == "get_IntProperty")
.Throws(new Exception());
driver.IntProperty = 3;
Assert.That(delegate { var i = driver.IntProperty; }, Throws.Exception);
}