Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#.Net核心Firebase FirestoreDb使用Moq模拟_Firebase_Unit Testing_Asp.net Core_Google Cloud Firestore_Moq - Fatal编程技术网

C#.Net核心Firebase FirestoreDb使用Moq模拟

C#.Net核心Firebase FirestoreDb使用Moq模拟,firebase,unit-testing,asp.net-core,google-cloud-firestore,moq,Firebase,Unit Testing,Asp.net Core,Google Cloud Firestore,Moq,我试图模拟FirestoreDb(Google.Cloud.Firestore)进行单元测试 但类签名是: public sealed class FirestoreDb {...} 因此,当我尝试模拟时,会出现以下错误: _firestoreDb = new Mock<FirestoreDb>(); \u firestoreDb=new Mock(); System.NotSupportedException:要模拟的类型必须是接口、委托或非密封的非静态类 是否有任何方法可以

我试图模拟FirestoreDb(Google.Cloud.Firestore)进行单元测试

但类签名是:

public sealed class FirestoreDb {...}
因此,当我尝试模拟时,会出现以下错误:

_firestoreDb = new Mock<FirestoreDb>();
\u firestoreDb=new Mock();
System.NotSupportedException:要模拟的类型必须是接口、委托或非密封的非静态类

是否有任何方法可以模拟该数据库,以便为保存到Firestore数据库的所有处理程序编写单元测试


谢谢

与您无法控制的第三方依赖项紧密耦合将导致您当前遇到的问题。考虑将这些依赖项封装在您所控制的抽象后面,并可以根据您的隔离单元测试的需要进行操作。请给出一个示例,说明您当前如何使用<代码> FixStReDeB/<代码> Apple FixStReDeb.文档($“Apvest/{ApdioPosial.Id}”)。SetAsync(AppultDebug,StestOpths.MelGeAL);@Nkosi虽然我通常认为耦合并不理想,但我们也不能总是为我们使用的每个库编写包装器。