本文整理汇总了C#中Syncano.Net.Api.DataObjectSyncanoClient.AddParent方法的典型用法代码示例。如果您正苦于以下问题:C# DataObjectSyncanoClient.AddParent方法的具体用法?C# DataObjectSyncanoClient.AddParent怎么用?C# DataObjectSyncanoClient.AddParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Syncano.Net.Api.DataObjectSyncanoClient
的用法示例。
在下文中一共展示了DataObjectSyncanoClient.AddParent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddParent_ByCollectionKey
public async Task AddParent_ByCollectionKey(DataObjectSyncanoClient client)
{
//given
var newParentRequest = new DataObjectDefinitionRequest();
newParentRequest.ProjectId = TestData.ProjectId;
newParentRequest.CollectionId = TestData.CollectionId;
var parentObject = await client.New(newParentRequest);
var newChildRequest = new DataObjectDefinitionRequest();
newChildRequest.ProjectId = TestData.ProjectId;
newChildRequest.CollectionId = TestData.CollectionId;
var childObject = await client.New(newChildRequest);
//when
var result =
await
client.AddParent(TestData.ProjectId, childObject.Id, parentObject.Id,
collectionKey: TestData.CollectionKey);
var getResult =
await
client.GetOne(TestData.ProjectId, TestData.CollectionId, dataId: parentObject.Id,
includeChildren: true);
//then
result.ShouldBeTrue();
getResult.Children.ShouldNotBeEmpty();
getResult.Children[0].Id.ShouldEqual(childObject.Id);
//cleanup
var deleteRequest = new DataObjectSimpleQueryRequest();
deleteRequest.ProjectId = TestData.ProjectId;
deleteRequest.CollectionId = TestData.CollectionId;
await client.Delete(deleteRequest);
}
示例2: AddParent_WithInvalidChildId_ThrowsException
public async Task AddParent_WithInvalidChildId_ThrowsException(DataObjectSyncanoClient client)
{
//given
var newParentRequest = new DataObjectDefinitionRequest();
newParentRequest.ProjectId = TestData.ProjectId;
newParentRequest.CollectionId = TestData.CollectionId;
var parentObject = await client.New(newParentRequest);
var newChildRequest = new DataObjectDefinitionRequest();
newChildRequest.ProjectId = TestData.ProjectId;
newChildRequest.CollectionId = TestData.CollectionId;
await client.New(newChildRequest);
try
{
//when
await
client.AddParent(TestData.ProjectId, "abc", parentObject.Id,
TestData.CollectionId);
throw new Exception("AddChild should throw an exception");
}
catch (Exception e)
{
//then
e.ShouldBeType<SyncanoException>();
}
//cleanup
var deleteRequest = new DataObjectSimpleQueryRequest();
deleteRequest.ProjectId = TestData.ProjectId;
deleteRequest.CollectionId = TestData.CollectionId;
await client.Delete(deleteRequest);
}