Exemplo n.º 1
0
        public async Task Owner()
        {
            var bucket = await _bucketsApi.CreateBucket(GenerateName("robot sensor"), RetentionRule(), _organization);

            var owners = await _bucketsApi.GetOwners(bucket);

            Assert.AreEqual(1, owners.Count);
            Assert.AreEqual("my-user", owners[0].Name);

            var user = await _usersApi.CreateUser(GenerateName("Luke Health"));

            var resourceMember = await _bucketsApi.AddOwner(user, bucket);

            Assert.IsNotNull(resourceMember);
            Assert.AreEqual(resourceMember.Id, user.Id);
            Assert.AreEqual(resourceMember.Name, user.Name);
            Assert.AreEqual(resourceMember.Role, ResourceOwner.RoleEnum.Owner);

            owners = await _bucketsApi.GetOwners(bucket);

            Assert.AreEqual(2, owners.Count);
            Assert.AreEqual(owners[1].Id, user.Id);
            Assert.AreEqual(owners[1].Name, user.Name);
            Assert.AreEqual(owners[1].Role, ResourceOwner.RoleEnum.Owner);

            await _bucketsApi.DeleteOwner(user, bucket);

            owners = await _bucketsApi.GetOwners(bucket);

            Assert.AreEqual(1, owners.Count);
        }