本文整理汇总了C#中DbSet.GetAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DbSet.GetAsync方法的具体用法?C# DbSet.GetAsync怎么用?C# DbSet.GetAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbSet
的用法示例。
在下文中一共展示了DbSet.GetAsync方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DbSetGetAsyncTest
public async Task DbSetGetAsyncTest()
{
//Arrange
var mockRestResponse = new Mock<IRestResponse>();
mockRestResponse.SetupGet(o => o.ResponseStatus).Returns(ResponseStatus.Completed);
mockRestResponse.SetupGet(o => o.StatusCode).Returns(HttpStatusCode.OK);
mockRestResponse.SetupGet(o => o.Content).Returns(@"{
""contactId"": ""48620"",
""id"": ""10002"",
""fieldValues"": [
{
""id"": ""824"",
""value"": ""transxId12321321321321""
}
],
""name"": ""Test Name WHAT IS THIS"",
""uri"": ""/data/customObject""
}
");
var mockRestClient = new Mock<IRestClient>();
mockRestClient.Setup(o => o.ExecuteTaskAsync(It.IsAny<IRestRequest>())).ReturnsAsync(mockRestResponse.Object);
var dbSet = new DbSet<MockDbsetWithDataContact>(mockRestClient.Object);
//Act
var contact = await dbSet.GetAsync(1, Depth.Complete);
//Assert
Assert.AreEqual(10002, contact.Id);
}
示例2: DbSetGetAsyncResourceAttributeNullTest
public async Task DbSetGetAsyncResourceAttributeNullTest()
{
//Arrange
var mockRestClient = new Mock<IRestClient>();
var dbSet = new DbSet<MockDbsetContact>(mockRestClient.Object);
//Act
await dbSet.GetAsync(1, Depth.Complete);
//Assert - throws
}