Microsoft.Azure के नवीनतम स्थिर संस्करण है। दस्तावेज़ डीबी (1.10.0) एटीएम ने मॉकिंग उद्देश्यों के लिए 2 रचनाकार जोड़े।
https://msdn.microsoft.com/en-us/library/azure/dn799209.aspx#Anchor_2
संपादित
Moq का उपयोग करके आप कुछ इस तरह कर सकता है:
Mock<IDocumentClient> documentClient = new Mock<IDocumentClient>();
documentClient
.Setup(dc => dc.ReplaceDocumentAsync(UriFactory.CreateDocumentUri("database", "collection", "id"), object, null) // last parameter are RequestOptions, these are null by default
.Returns(Task.FromResult(new ResourceResponse<Document>()));
इस तरह अगर आप चाहते हैं मैं देख सकते हैं कि मेरी documentClient पर विधि बुलाया जा रहा है, दस्तावेज़ में जो भी लौटाया गया है उसे प्रभावित करने के लिए, आपको एक दस्तावेज़ बनाना होगा, और उस दस्तावेज़ के संसाधन संसाधन का पालन करना होगा। कुछ ऐसा:
var document = new Document();
document.LoadFrom(jsonReader); // the json reader should contain the json of the document you want to return
Mock<IDocumentClient> documentClient = new Mock<IDocumentClient>();
documentClient
.Setup(dc => dc.ReplaceDocumentAsync(UriFactory.CreateDocumentUri("database", "collection", "id"), object, null) // last parameter are RequestOptions, these are null by default
.Returns(Task.FromResult(new ResourceResponse<Document>(document)));
"सक्षम नहीं" परिभाषित करें। आपका प्रश्न इस वर्ग के लिए विशिष्ट नहीं है। क्या आपका मतलब है कि यह मुहरबंद है और उसे निजी, संरक्षित या आंतरिक कन्स्ट्रक्टर मिला है? फिर उस पर खोजें। वैसे भी एक वेब सेवा के लिए क्लाइंट लाइब्रेरी को केवल सीलबंद कक्षाओं के साथ उजागर करना थोड़ा मूर्खतापूर्ण है, माइक्रोसॉफ्ट को दोष दें। – CodeCaster
हां, यह एक [मुहरबंद वर्ग] है (https://msdn.microsoft.com/en-us/library/azure/dn799209.aspx) – DavidG
क्या कोई कारखाना वर्ग है जो इसे तुरंत चालू करता है? –