Beispiel #1
0
        public void FuncCallTest()
        {
            Func <IMock, string> func = m => m.MethodWithReturn();

            var expected = _faker.Random.String();

            _mock.MethodWithReturn().Returns(expected);
            var mock   = ExpressionShortcuts.Arg(_mock);
            var data   = ExpressionShortcuts.Var <IMock>();
            var action = ExpressionShortcuts.Block()
                         .Parameter(data, mock)
                         .Line(ExpressionShortcuts.Call(() => func((IMock)data)))
                         .Lambda <Func <string> >()
                         .Compile();

            _mock.DidNotReceive().MethodWithReturn();

            var actual = action();

            Assert.Equal(expected, actual);

            _mock.Received(1).MethodWithReturn();
        }