devlooped/moq

DefaultValue.Empty and DefaultValue.Mock should support C# 7 tuple return types

Closed this issue · 0 comments

stakx commented

C# 7 introduced language syntax for tuples (System.ValueTuple<…>), Moq should probably support them. For example, given these types:

public interface IFoo
{
    (IBar, IEnumerable<string>) GetThings();
}

public interface IBar { }

The following test should pass:

[Fact]
public void DefaultValue_Mock_supports_tuple_return_types()
{
    var mock = new Mock<IFoo>() { DefaultValue.Mock };
    var (bar, strings) = mock.Object.GetThings();

    Assert.NotNull(bar);
    Assert.IsAssignableFrom<IBar>(bar);

    Assert.NotNull(strings);
    Assert.Empty(strings);
}

(Same goes for DefaultValue.Empty.)