I want to create a new test with a regression test as the parent using the VersionOne .Net SDK. This code throws Violation'Required'AttributeDefinition'Parent'Test: NULL
on the line _services.Save(newAsset)
This is the code I am using:
var parentAssetType = "RegressionTest";
var typeOfAsset = "Test";
var assetTitle = "My New Test";
public Asset AddNewAsset(string parentAssetType, string typeOfAsset, string assetTitle)
{
var projectId = Oid.FromToken(parentAssetType + ":0", _metaModel);
Console.WriteLine(projectId.Token);
var assetType = _metaModel.GetAssetType(typeOfAsset);
var newAsset = _services.New(assetType, projectId);
var nameAttribute = assetType.GetAttributeDefinition("Name");
newAsset.SetAttributeValue(nameAttribute, assetTitle);
_services.Save(newAsset);
var newAssetId = newAsset.Oid.Token;
var parentAssetId = newAsset.GetAttribute(assetType.GetAttributeDefinition(parentAssetType)).Value;
var newAssetName = newAsset.GetAttribute(nameAttribute).Value;
_logger.Log(Loglevel.Debug, "New Asset Id:{0} --- Parent Asset Id:{1} --- New Asset Name:{2}", newAssetId, parentAssetId, newAssetName);
Console.WriteLine("New Asset Id:{0} --- Parent Asset Id:{1} --- New Asset Name:{2}", newAssetId, parentAssetId, newAssetName);
return newAsset;
}
I am closely following the exampele found here: https://github.com/versionone/VersionOne.SDK.NET.APIClient#learn-by-example-new-asset
In the paragraph before the example, the author explains "When you create a new asset in the APIClient you need to specify the "context" of another asset that will be the parent. For example, if you create a new Story asset you can specify which Scope it should be created in".
In the example the parentAssetType
is set to "Scope:0"
. However, I think it is supposed to be a specific id of an already existing asset. I tried this code with a real existing scope number and the same error was thrown which leads me to believe I am missing the real problem.