1

メンバーが以下のような戻り値を指定する必要があるインスタンスを偽造するタイプモック テストがあるとします。

WallLayers layers = Isolate.Fake.Instance<WallLayers>(Members.MustSpecifyReturnValues);
Isolate.WhenCalled(() => layers.GetCoreProfile()).CallOriginal();

元の GetCoreProfile メソッド内に linq クエリがある場合

wallPoints = fe.GetFacePointsConstrainedBy<Int32>(FaceExtractor.BottomFace, constraints, selector1)
               .Where(p => p.Z == wallReferenceLevel)

テストを実行すると、次の例外がスローされます

TypeMock.TypeMockException: 
*** Unexpected Call to AU.Com.Monarch.Model.Revit.WallLayers.<GetCoreProfile()
   at dm.b(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
   at Typemock.Interceptors.Profiler.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType, Object p1)
   at AU.Com.Monarch.Model.Revit.WallLayers.<>c__DisplayClass1a.<GetCoreProfile>b__8(Point3D`1 p) in C:\revitMBS\source\ExternalFrame\ExternalFrame\Monarch\Model\Revit\WallLayers.cs:line 278
  1. linq 関数でも Typemock を CallOriginal にする方法はありますか?
  2. または、Members.MustSpecifyReturnValues のコンテキストでこれらの関数を無視する方法はありますか
  3. または、この状況で Member.MustSpecifyReturnValues を削除する唯一のオプションですか?

事前にご入力いただきありがとうございます。

4

0 に答える 0