コード例 #1
0
        public async Task WhenTheIMSUserPostsNewEntitiesWhereIsInAnERCollectionTimeS(int numOfEntities, string asyncHeader, string asyncValue, string version, int numOfTimes)
        {
            restClientUser = "******";
            for (int i = 0; i < numOfEntities; i++)
            {
                var newEntity = new Entity(id: $"test-{Guid.NewGuid()}", entityType: BrickEntityTypes.FloorBrickEntityType, entityName: "test entity");
                scenarioContext.AddEntity(newEntity);
            }
            // var erCollectionId = "test-" + Guid.NewGuid().ToString();
            string erCollectionId = this.scenarioContext.Get <dynamic>("CollectionsResponse");

            scenarioContext.AddERCollections(erCollectionId);
            var headers = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>(PlatformHeaders.ErCollectionId, erCollectionId),
                new KeyValuePair <string, string>(asyncHeader, asyncValue)
            };
            var getentities = scenarioContext.CreatedEntities().ToList();


            Log.Information($"Attempting to post new entity/entities in ER collection {erCollectionId}");
            for (int i = 0; i < numOfTimes; i++)
            {
                RestClientResponse <PlatformItemResponse> postEntityResponseMsg = null;
                try
                {
                    postEntityResponseMsg = await ERService.PostEntities(version, getentities, headers);
                }
                catch (RestClientException ex)
                {
                    scenarioContext.AddRestClientExceptionErrors(ex);
                }
            }
        }
        public async Task WhenTheIMSUserPostsNewRelationshipSBetweenTheEntitiesWhereIsWithInvalidSourceEntityIdUsingVInTheERCollectionTimeS(int numOfRelationship, string asyncHeader, string asyncValue, string version)
        {
            restClientUser = "******";
            for (int i = 0; i < numOfRelationship; i++)
            {
                int index       = i;
                var NewEntities = scenarioContext.CreatedEntities().ToList();
                while (NewEntities.Count <= index + 1)
                {
                    index = index + 1 - NewEntities.Count;
                }

                var          sourceEntityId      = NewEntities[index].Id;
                var          destinationEntityId = NewEntities[index + 1].Id;
                Relationship newRelationship     = null;
                newRelationship = new Relationship(id: $"test-{Guid.NewGuid()}", relationshipType: BrickRelationshipTypes.BrickEquipmentIsLocatedInLocation, relationshipName: "test relationship", sourceEntityId: $"test-{sourceEntityId}", destinationEntityId: destinationEntityId);
                scenarioContext.AddRelationship(newRelationship);
            }
            var erCollectionIdList = scenarioContext.CreatedERCollections().ToList();

            for (int i = 0; i < erCollectionIdList.Count; i++)
            {
                var headers = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>(PlatformHeaders.ErCollectionId, erCollectionIdList[i]),
                    new KeyValuePair <string, string>(asyncHeader, asyncValue)
                };
                var getRelationships = scenarioContext.CreatedRelationships().ToList();

                Log.Information($"Attempting to post new Relationship/Relationships between Entities synchronously in ER collection {erCollectionIdList[i]}");
                RestClientResponse <PlatformItemResponse> postRelationshipResponseMsg = null;
                try
                {
                    postRelationshipResponseMsg = await ERService.PostRelationship(version, getRelationships, headers);
                }
                catch (RestClientException ex)
                {
                    scenarioContext.AddRestClientExceptionErrors(ex);
                }
            }
        }