This project is read-only.
1
Vote

Calls to generic methods support

description

Repro from Yan Cui: https://gist.github.com/theburningmonk/438ebe15b99ffd635da2
public interface IDynamoDataAccessLayer
{
      void Save<T>(T entity, string config = null);
      void Save2<T>(T entity);
      void Save3(string entity);
}


let dal =
     Mock<IDynamoDataAccessLayer>()
        .Setup(fun x -> <@ x.Save(any(), any()) @>)
        .Calls<_>(fun x -> printfn "%A" x)
        .Setup(fun x -> <@ x.Save2(any()) @>)
        .Calls<_>(fun x -> printfn "%A" x)
        .Setup(fun x -> <@ x.Save3(any()) @>)
        .Calls<_>(fun x -> printfn "%A" x)
        .Create()

dal.Save(42)  // doesn't work
dal.Save2(42) // doesn't work
dal.Save3("42") // works


// tried this (explicit type for Call<int>) as well, same thing
let dal =
    Mock<IDynamoDataAccessLayer>()
        .Setup(fun x -> <@ x.Save(any(), any()) @>)
        .Calls<int>(fun x -> printfn "%d" x)
        .Setup(fun x -> <@ x.Save2(any()) @>)
        .Calls<int>(fun x -> printfn "%d" x)
        .Setup(fun x -> <@ x.Save3(any()) @>)
        .Calls<_>(fun x -> printfn "%A" x)
        .Create()

dal.Save(42)  // doesn't work
dal.Save2(42) // doesn't work
dal.Save3("42") // works

comments