本文整理汇总了C#中Syncano.Net.Api.DataObjectSyncanoClient.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# DataObjectSyncanoClient.AddChild方法的具体用法?C# DataObjectSyncanoClient.AddChild怎么用?C# DataObjectSyncanoClient.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Syncano.Net.Api.DataObjectSyncanoClient
的用法示例。
在下文中一共展示了DataObjectSyncanoClient.AddChild方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddChild_ByCollectionKey
public async Task AddChild_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.AddChild(TestData.ProjectId, parentObject.Id, childObject.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: RemoveChild_WithInvalidChildId_ThrowsException
public async Task RemoveChild_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.RemoveChild(TestData.ProjectId, parentObject.Id, "abc", TestData.CollectionId);
throw new Exception("RemoveChild 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: RemoveChild_WithNullChildId_RemovesAllChildren
public async Task RemoveChild_WithNullChildId_RemovesAllChildren(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.RemoveChild(TestData.ProjectId, parentObject.Id, collectionId: TestData.CollectionId);
//then
result.ShouldBeTrue();
//cleanup
var deleteRequest = new DataObjectSimpleQueryRequest();
deleteRequest.ProjectId = TestData.ProjectId;
deleteRequest.CollectionId = TestData.CollectionId;
await client.Delete(deleteRequest);
}
示例4: RemoveChild_ByCollectionKey_WithOtherChildren
public async Task RemoveChild_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.RemoveChild(TestData.ProjectId, parentObject.Id, childObject.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);
}
示例5: RemoveParent_ByCollectionId_WithoutParentId
public async Task RemoveParent_ByCollectionId_WithoutParentId(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, collectionId: TestData.CollectionId);
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);
}