Unplanned
Last Updated: 18 Sep 2020 14:24 by ADMIN
Ivo
Created on: 18 Sep 2020 14:23
Type: Feature Request
0
Mock interfaces with default implementations

C# 8 introduces default interface method implementations. Attempt to mock such methods with JustMock in elevated mode fails. The following example illustrates the issue:

public interface IMyInterface
{
    int IntProperty { get => 0; }
}


[TestClass]
public class UnitTest1
{
    [TestMethod]
    public void TestMethod1()
    {
        var mock = Mock.Create<IMyInterface>();
        Mock.Arrange(() => mock.IntProperty).Returns(1);

        Assert.AreEqual(1, mock.IntProperty);
    }
}

 

 

 
0 comments