public void Test_2() { IVisitIObjectAttribute iviv = Substitute.For<IVisitIObjectAttribute>(); MyObject mo = new MyObject("Simple", 65); Expression<Func<int>> myexpression = () => mo.Value; ExpressionVisitorFunction<int> evf = new ExpressionVisitorFunction<int>(myexpression); Func<IVisitIObjectAttribute, int> func = evf.Transformed.Compile(); int res = func(iviv); res.Should().Be(65); iviv.DidNotReceive().Visit(Arg.Any<INotifyCollectionChanged>()); iviv.Received().Visit(mo, Arg.Any<PropertyInfo>(), false); }
public void Test_1() { IVisitIObjectAttribute iviv = Substitute.For<IVisitIObjectAttribute>(); Expression<Func<int>> myexpression = () => 35; ExpressionVisitorFunction<int> evf = new ExpressionVisitorFunction<int>(myexpression); Func<IVisitIObjectAttribute, int> func = evf.Transformed.Compile(); int res = func(iviv); res.Should().Be(35); iviv.DidNotReceive().Visit(Arg.Any<INotifyCollectionChanged>()); iviv.DidNotReceive().Visit(Arg.Any<IObjectAttribute>(), Arg.Any<PropertyInfo>(), Arg.Any<bool>()); }