You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Moq (4.7.142) does not recognize all sealed methods as uninterceptable. Given a sealed overridden property in a derived class, it does not throw an exception when an attempt is made to Setup that property:
publicabstractclassFooBase{publicabstractobjectProperty{get;}}publicclassFoo:FooBase{publicsealedoverrideobjectProperty=>null;}[Fact]// does not passpublicvoidCannot_setup_virtual_sealed_property(){// verify that Property is both virtual and sealed:varpropertyGetter=typeof(Foo).GetProperty("Property").GetGetMethod();
Assert.True(propertyGetter.IsVirtual && propertyGetter.IsFinal);// arrange:varfooMock=newMock<Foo>();// act:varexception= Record.Exception(()=>{ fooMock.Setup(foo => foo.Property).Returns("mocked");});varproperty= fooMock.Object.Property;// assert:
Assert.NotEqual("mocked", property);// Moq shouldn't be able to intercept a sealed property
Assert.NotNull(exception);// and warn us by throwing an exception.}
The text was updated successfully, but these errors were encountered:
Moq (4.7.142) does not recognize all sealed methods as uninterceptable. Given a sealed overridden property in a derived class, it does not throw an exception when an attempt is made to
Setup
that property:The text was updated successfully, but these errors were encountered: