Example #1
0
        public void UsageExample()
        {
            var setPropRequest = new SetPropertiesRequest(_project);

            setPropRequest.SetProperty("mytestapp.metrics.magicnumber").SetContentString("42");
            //setPropRequest.SetProperty("mytestapp.inputs.appresults").SetContentReferencesArray(new[] { "appresults/3006", "appresults/3005" });
            var map = new PropertyContentMap();

            map.Add("label.x-axis", "energydrinks");
            map.Add("label.y-axis", "productivity");
            map.Add("series.x-axis", "0", "1", "2", "3", "4");
            map.Add("series.y-axis", "5", "7", "8", "4", "1");

            setPropRequest.SetProperty("mytestapp.inputs.metrics").SetContentMap(map);

            // Create some properties
            // POST: resource/{id}/properties
            var properties = Client.SetPropertiesForResource(setPropRequest).Response.Items;

            // list those properties
            // GET: resource/{id}/properties
            properties = Client.ListPropertiesForResource(new ListPropertiesRequest(_project)).Response.Items;

            // they also show up here
            // GET: resource/{id}
            properties = Client.GetProject(new GetProjectRequest(_project.Id)).Response.Properties.Items;

            // take a deeper dive into the items list
            // GET: resource/{id}/properties/{name}/items
            var propertyItems = Client.ListPropertyItems(new ListPropertyItemsRequest(_project, "mytestapp.inputs.appresults")).Response.Items;

            // delete a property
            // DELETE: resource/{id}/properties/{name}
            Client.DeletePropertyForResource(new DeletePropertyRequest(_project, "mytestapp.inputs.appresults"));
        }
Example #2
0
        public void MapArray()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var h1             = new PropertyContentMap();

            h1.Add("a1", "r1", "r1a", "r1a");
            h1.Add("a2", "r2");

            var h2 = new PropertyContentMap();

            h2.Add("b1", "b1a", "b1b", "b1c");
            h2.Add("b2", "b2a");


            setPropRequest.SetProperty("unittest.hash.multivalue").SetContentMapArray(new[] { h1, h2 });
            var props = Client.SetPropertiesForResource(setPropRequest).Response;

            Assert.Equal(1, props.Items.Count());

            var prop = props.Items.First();

            Assert.Equal(PropertyTypes.MAP + PropertyTypes.LIST_SUFFIX, prop.Type);
            Assert.Equal(2, prop.Items.Count());
            Assert.Equal(2, prop.ItemsDisplayedCount);
            Assert.Equal(2, prop.ItemsTotalCount);

            Assert.Equal(new[] { "r1", "r1a", "r1a" }, prop.Items[0].ToMap()["a1"].Values);
            Assert.Equal(new[] { "r2" }, prop.Items[0].ToMap()["a2"].Values);

            Assert.Equal(new[] { "b1a", "b1b", "b1c" }, prop.Items[1].ToMap()["b1"].Values);
            Assert.Equal(new[] { "b2a" }, prop.Items[1].ToMap()["b2"].Values);
        }
        public void AddEmptyKeyNameMap()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var hash = new PropertyContentMap();
            hash.Add(string.Empty, "value");
            setPropRequest.SetProperty("unittest.hash.empty").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_KEY_INVALID", HttpStatusCode.BadRequest);
        }
Example #4
0
        public void AddEmptyKeyNameMap()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var hash           = new PropertyContentMap();

            hash.Add(string.Empty, "value");
            setPropRequest.SetProperty("unittest.hash.empty").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_KEY_INVALID", HttpStatusCode.BadRequest);
        }
Example #5
0
        public void SingleValueMapDupes()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var hash           = new PropertyContentMap();

            hash.Add("rainbow", RAINBOW);
            hash.Add("rainbow", "value2");
            setPropRequest.SetProperty("unittest.hash.dupe").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_DUPES", HttpStatusCode.BadRequest);
        }
        public void AddEmptyMapList()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var hash = new PropertyContentMap();
            setPropRequest.SetProperty("unittest.hash.empty").SetContentMap(hash);

            var propResponse = Client.SetPropertiesForResource(setPropRequest).Response;
            var prop = propResponse.Items.FirstOrDefault(p => p.Name == "unittest.hash.empty");
            Assert.NotNull(prop);
            Assert.Equal("map", prop.Type);
            Assert.Equal(null, prop.ToMapArray());
        }
Example #7
0
        public void AddEmptyMapList()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var hash           = new PropertyContentMap();

            setPropRequest.SetProperty("unittest.hash.empty").SetContentMap(hash);

            var propResponse = Client.SetPropertiesForResource(setPropRequest).Response;
            var prop         = propResponse.Items.FirstOrDefault(p => p.Name == "unittest.hash.empty");

            Assert.NotNull(prop);
            Assert.Equal("map", prop.Type);
            Assert.Equal(null, prop.ToMapArray());
        }
Example #8
0
        public void AddInvalidKeyNameMap()
        {
            var setPropRequest = new SetPropertiesRequest(_project);

            var hash = new PropertyContentMap();

            hash.Add("ab$c", "value");
            setPropRequest.SetProperty("unittest.hash.invalidkey").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_KEY_INVALID", HttpStatusCode.BadRequest);

            hash = new PropertyContentMap();
            hash.Add("unittest.singlevalue.propertynamegreaterthan64.01234567891234567890", "value");
            setPropRequest = new SetPropertiesRequest(_project);
            setPropRequest.SetProperty("unittest.hash.invalidkey").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_KEY_INVALID", HttpStatusCode.BadRequest);
        }
Example #9
0
        public void SingleValueMap()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var map            = new PropertyContentMap();

            map.Add("rainbow", RAINBOW);
            map.Add("key2", "value2");
            map.Add("rainbow2", RAINBOW);

            setPropRequest.SetProperty("unittest.hash").SetContentMap(map);
            var prop = Client.SetPropertiesForResource(setPropRequest).Response.Items.FirstOrDefault();

            Assert.NotNull(prop);
            Assert.Equal(PropertyTypes.MAP, prop.Type);
            Assert.NotNull(prop.Content);
            map = prop.Content.ToMap();
            Assert.NotNull(map);
            Assert.NotNull(map.FirstOrDefault(h => h.Key == "rainbow"));
            Assert.True(map.FirstOrDefault(h => h.Key == "rainbow").Values.All(v => RAINBOW.Contains(v)));
            Assert.Equal(3, map.Count());
        }
        public void AddInvalidKeyNameMap()
        {
            var setPropRequest = new SetPropertiesRequest(_project);

            var hash = new PropertyContentMap();
            hash.Add("ab$c", "value");
            setPropRequest.SetProperty("unittest.hash.invalidkey").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_KEY_INVALID", HttpStatusCode.BadRequest);

            hash = new PropertyContentMap();
            hash.Add("unittest.singlevalue.propertynamegreaterthan64.01234567891234567890", "value");
            setPropRequest = new SetPropertiesRequest(_project);
            setPropRequest.SetProperty("unittest.hash.invalidkey").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_KEY_INVALID", HttpStatusCode.BadRequest);
        }
        public void UsageExample()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            setPropRequest.SetProperty("mytestapp.metrics.magicnumber").SetContentString("42");
            //setPropRequest.SetProperty("mytestapp.inputs.appresults").SetContentReferencesArray(new[] { "appresults/3006", "appresults/3005" });
            var map = new PropertyContentMap();
            map.Add("label.x-axis", "energydrinks");
            map.Add("label.y-axis", "productivity");
            map.Add("series.x-axis", "0", "1", "2", "3", "4");
            map.Add("series.y-axis", "5", "7", "8", "4", "1");

            setPropRequest.SetProperty("mytestapp.inputs.metrics").SetContentMap(map);

            // Create some properties
            // POST: resource/{id}/properties
            var properties = Client.SetPropertiesForResource(setPropRequest).Response.Items;

            // list those properties
            // GET: resource/{id}/properties
            properties = Client.ListPropertiesForResource(new ListPropertiesRequest(_project)).Response.Items;

            // they also show up here
            // GET: resource/{id}
            properties = Client.GetProject(new GetProjectRequest(_project.Id)).Response.Properties.Items;

            // take a deeper dive into the items list
            // GET: resource/{id}/properties/{name}/items
            var propertyItems = Client.ListPropertyItems(new ListPropertyItemsRequest(_project, "mytestapp.inputs.appresults")).Response.Items;

            // delete a property
            // DELETE: resource/{id}/properties/{name}
            Client.DeletePropertyForResource(new DeletePropertyRequest(_project, "mytestapp.inputs.appresults"));
        }
        public void SingleValueMapDupes()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var hash = new PropertyContentMap();
            hash.Add("rainbow", RAINBOW);
            hash.Add("rainbow", "value2");
            setPropRequest.SetProperty("unittest.hash.dupe").SetContentMap(hash);

            AssertErrorResponse(() => Client.SetPropertiesForResource(setPropRequest), "BASESPACE.PROPERTIES.CONTENT_MAP_DUPES", HttpStatusCode.BadRequest);
        }
        public void SingleValueMap()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var map = new PropertyContentMap();
            map.Add("rainbow", RAINBOW);
            map.Add("key2", "value2");
            map.Add("rainbow2", RAINBOW);

            setPropRequest.SetProperty("unittest.hash").SetContentMap(map);
            var prop = Client.SetPropertiesForResource(setPropRequest).Response.Items.FirstOrDefault();
            Assert.NotNull(prop);
            Assert.Equal(PropertyTypes.MAP, prop.Type);
            Assert.NotNull(prop.Content);
            map = prop.Content.ToMap();
            Assert.NotNull(map);
            Assert.NotNull(map.FirstOrDefault(h=>h.Key == "rainbow"));
            Assert.True(map.FirstOrDefault(h => h.Key == "rainbow").Values.All(v => RAINBOW.Contains(v)));
            Assert.Equal(3, map.Count());
        }
        public void MapArray()
        {
            var setPropRequest = new SetPropertiesRequest(_project);
            var h1 = new PropertyContentMap();
            h1.Add("a1", "r1", "r1a", "r1a");
            h1.Add("a2", "r2");

            var h2 = new PropertyContentMap();
            h2.Add("b1", "b1a", "b1b", "b1c");
            h2.Add("b2", "b2a");

            setPropRequest.SetProperty("unittest.hash.multivalue").SetContentMapArray(new[] {h1, h2});
            var props = Client.SetPropertiesForResource(setPropRequest).Response;
            Assert.Equal(1, props.Items.Count());

            var prop = props.Items.First();

            Assert.Equal(PropertyTypes.MAP + PropertyTypes.LIST_SUFFIX, prop.Type);
            Assert.Equal(2, prop.Items.Count());
            Assert.Equal(2, prop.ItemsDisplayedCount);
            Assert.Equal(2, prop.ItemsTotalCount);

            Assert.Equal(new[] { "r1", "r1a", "r1a" }, prop.Items[0].ToMap()["a1"].Values);
            Assert.Equal(new[] { "r2" }, prop.Items[0].ToMap()["a2"].Values);

            Assert.Equal(new[] { "b1a", "b1b", "b1c" }, prop.Items[1].ToMap()["b1"].Values);
            Assert.Equal(new[] { "b2a" }, prop.Items[1].ToMap()["b2"].Values);
        }
 public void SetContentMap(PropertyContentMap map)
 {
     ContentMap = map;
     Items      = null;
 }