Beispiel #1
0
        public void ApiDeleteEntities(EntityFactory entityFactory)
        {
            // create some test entities over the api to run the delete tests against
            var entityList = entityFactory.ConstructAndSave(_output, 1);

            foreach (var entityObject in entityList)
            {
                // instantiate a list of entity names and guids to be deleted
                var entityKeysGuids = new List <KeyValuePair <string, Guid> >();
                entityKeysGuids.Add(new KeyValuePair <string, Guid>(entityObject.EntityName, entityObject.Id));

                // populate the list using information returned from create entities.
                GetParentKeysGuids(entityObject).ForEach(x => entityKeysGuids.Add(x));

                foreach (var entityKeyGuid in entityKeysGuids)
                {
                    // instantiate a new rest client, and configure the Uri

                    var endPoint = $"/api/entity/{entityKeyGuid.Key}/{entityKeyGuid.Value}";
                    var api      = new WebApi(_configure, _output);
                    api.ConfigureAuthenticationHeaders();

                    Assert.Equal(HttpStatusCode.OK, api.Get(endPoint).StatusCode);
                    Assert.Equal(HttpStatusCode.OK, api.Delete(endPoint).StatusCode);
                    Assert.Equal(HttpStatusCode.NoContent, api.Get(endPoint).StatusCode);
                    Assert.Equal(HttpStatusCode.OK, api.Delete(endPoint).StatusCode);
                }
            }
        }