Esempio n. 1
0
        public void ReOpenAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices  services  = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story
            var projectId     = Oid.FromToken("Scope:0", metaModel);
            var assetType     = metaModel.GetAssetType("Story");
            var story         = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");

            story.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(story);

            // closes the story
            var closeOperation = metaModel.GetOperation("Story.Inactivate");
            var closeId        = services.ExecuteOperation(closeOperation, story.Oid);

            //reopens the story
            var activateOperation = metaModel.GetOperation("Story.Reactivate");
            var activeId          = services.ExecuteOperation(activateOperation, story.Oid);

            var query      = new Query(activeId.Momentless);
            var assetState = metaModel.GetAttributeDefinition("Story.AssetState");

            query.Selection.Add(assetState);
            var   result      = services.Retrieve(query);
            Asset activeStory = result.Assets[0];

            Assert.AreEqual("Active", activeStory.GetAttribute(assetState).Value.ToString());
        }
Esempio n. 2
0
        public void DeleteAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices  services  = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story so we can delete it
            var projectId     = Oid.FromToken("Scope:0", metaModel);
            var assetType     = metaModel.GetAssetType("Story");
            var newStory      = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");

            newStory.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(newStory);
            // delete the story
            var         deleteOperation = metaModel.GetOperation("Story.Delete");
            var         deletedId       = services.ExecuteOperation(deleteOperation, newStory.Oid);
            var         query           = new Query(deletedId.Momentless);
            QueryResult result          = services.Retrieve(query);

            Assert.AreEqual(0, result.TotalAvaliable);

            // The delete operation returns the Oid with the new Moment of the deleted asset.
            // Future queries will automatically exclude deleted assets from results.
            // Currently there is no support for undeleting a deleted asset.
        }
Esempio n. 3
0
 protected void ExecuteOperationInV1(string Operation, Oid AssetOID)
 {
     try
     {
         IOperation operation = _metaAPI.GetOperation(Operation);
         Oid        oid       = _dataAPI.ExecuteOperation(operation, AssetOID);
     }
     catch (APIException ex)
     {
         return;
     }
 }
        public void ReOpenAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story
            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var story = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            story.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(story);

            // closes the story
            var closeOperation = metaModel.GetOperation("Story.Inactivate");
            var closeId = services.ExecuteOperation(closeOperation, story.Oid);

            //reopens the story
            var activateOperation = metaModel.GetOperation("Story.Reactivate");
            var activeId = services.ExecuteOperation(activateOperation, story.Oid);

            var query = new Query(activeId.Momentless);
            var assetState = metaModel.GetAttributeDefinition("Story.AssetState");
            query.Selection.Add(assetState);
            var result = services.Retrieve(query);
            Asset activeStory = result.Assets[0];

            Assert.AreEqual("Active", activeStory.GetAttribute(assetState).Value.ToString());
        }
        public void DeleteAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story so we can delete it
            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var newStory = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            newStory.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(newStory);
            // delete the story
            var deleteOperation = metaModel.GetOperation("Story.Delete");
            var deletedId = services.ExecuteOperation(deleteOperation, newStory.Oid);
            var query = new Query(deletedId.Momentless);
            QueryResult result = services.Retrieve(query);

            Assert.AreEqual(0, result.TotalAvaliable);

            // The delete operation returns the Oid with the new Moment of the deleted asset. 
            // Future queries will automatically exclude deleted assets from results.
            // Currently there is no support for undeleting a deleted asset.
        }