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
IDE: Visual Studio 2019
.NET: Framework 4.5.2
Unit Test: nUnit 3.7.0
Runner: ReSharper 2019.1
Property stubs on sub mocks aren't working as expected. The stub now has to be set using Mock.Get(mock.Object.Inner) in order for it to work. It was broken in 4.17.1 (works in 4.16.1, did not test in 4.17.0).
public interface IFoo { IBar Bar { get; } }
public interface IBar
{
string Prop1 { get; }
string Prop2 { get; set; }
}
[TestFixture]
public class Tests
{
[Test]
public void Test()
{
const prop2 = "Prop2";
var mock = new Mock<IFoo>();
mock.SetupGet(m => m.Bar.Prop1).Returns("Prop1"); // FYI, if this is not included, the setter two lines below throws a NRE. That's also new
// this just happened to be our particular use case
mock.SetupProperty(m => m.Bar.Prop2);
mock.Object.Bar.Prop2 = prop2;
Assert.AreEqual(prop2, mock.Object.Bar.Prop2);
}
}
The text was updated successfully, but these errors were encountered:
This was indeed a regression... thanks again for reporting it. You were also right that both problems had the same underlying cause. They should be fixed now. An updated version 4.17.2 should become available on NuGet shortly.
Those unit tests look suspiciously familiar ;) Thanks for jumping on this.
If you don't mind holding off on 4.17.2 for another day or two, I've got another possible regression around clearing Invocations that happened in 4.15.1. I haven't had a chance to nail down the exact repro steps yet.
IDE: Visual Studio 2019
.NET: Framework 4.5.2
Unit Test: nUnit 3.7.0
Runner: ReSharper 2019.1
Property stubs on sub mocks aren't working as expected. The stub now has to be set using Mock.Get(mock.Object.Inner) in order for it to work. It was broken in 4.17.1 (works in 4.16.1, did not test in 4.17.0).
The text was updated successfully, but these errors were encountered: