예제 #1
0
        public async Task Labels()
        {
            var labelClient = Client.GetLabelsApi();

            var bucket = await _bucketsApi.CreateBucket(GenerateName("robot sensor"), RetentionRule(), _organization);

            var properties = new Dictionary <string, string> {
                { "color", "green" }, { "location", "west" }
            };

            var label = await labelClient.CreateLabel(GenerateName("Cool Resource"), properties, _organization.Id);

            var labels = await _bucketsApi.GetLabels(bucket);

            Assert.AreEqual(0, labels.Count);

            var addedLabel = await _bucketsApi.AddLabel(label, bucket);

            Assert.IsNotNull(addedLabel);
            Assert.AreEqual(label.Id, addedLabel.Id);
            Assert.AreEqual(label.Name, addedLabel.Name);
            Assert.AreEqual(label.Properties, addedLabel.Properties);

            labels = await _bucketsApi.GetLabels(bucket);

            Assert.AreEqual(1, labels.Count);
            Assert.AreEqual(label.Id, labels[0].Id);
            Assert.AreEqual(label.Name, labels[0].Name);

            await _bucketsApi.DeleteLabel(label, bucket);

            labels = await _bucketsApi.GetLabels(bucket);

            Assert.AreEqual(0, labels.Count);
        }