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