Activate() public method

Activates specified collection.
public Activate ( string projectId, string collectionId, bool force = false ) : Task
projectId string Project id.
collectionId string Collection id defining collection to be activated.
force bool If set to True, will force the activation by deactivating all other collections that may share it's data_key.
return Task
        public async Task Authorize_ByCollectionKey(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            string collectionKey = "qwert";

            var collection =
                await client.New(TestData.ProjectId, collectionName, collectionKey);
            await client.Activate(TestData.ProjectId, collection.Id, true);

            //when
            var result =
                await
                    client.Authorize(TestData.UserApiClientId, Permissions.UpdateOwnData,
                        TestData.ProjectId, collectionKey: collectionKey);

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Deauthorize(TestData.UserApiClientId, Permissions.UpdateOwnData,
                        TestData.ProjectId, collection.Id);
            await client.Delete(TestData.ProjectId, collection.Id);
        }
        public async Task Deactivate_ByCollectionId(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            string collectionKey = "qwert";

            var collection =
                await client.New(TestData.ProjectId, collectionName, collectionKey);
            await client.Activate(TestData.ProjectId, collection.Id, true);

            //when
            var result = await client.Deactivate(TestData.ProjectId, collection.Id);

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
        public async Task Update_ByCollectionId_NewCollectionKey(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            string collectionKey = "qwert";
            string collectionDescription = "abcde";
            string newCollectionName = "New name " + collectionName;
            string newKey = "newKey value";

            var collection =
                await client.New(TestData.ProjectId, collectionName, collectionKey);
            await client.Activate(TestData.ProjectId, collection.Id, true);

            //when
            collection =
                await
                    client.Update(TestData.ProjectId, collection.Id, collectionKey: newKey, name: newCollectionName,
                        description: collectionDescription);

            //then
            collection.ShouldNotBeNull();
            collection.Key.ShouldEqual(newKey);
            collection.Name.ShouldEqual(newCollectionName);
            collection.Description.ShouldEqual(collectionDescription);

            //cleanup
            await client.Delete(TestData.ProjectId, collectionKey: collection.Key);
        }
 public async Task Activate_InvalidCollectionId(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.Activate(TestData.ProjectId, "abcde");
         throw new Exception("Activate should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
 public async Task Activate_NullCollectionId(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.Activate(TestData.ProjectId, null);
         throw new Exception("Activate should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }
        public async Task GetOne_ByCollectionKey_GetsCollectionObject(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            string collectionKey = "abcde";

            var collection =
                await client.New(TestData.ProjectId, collectionName, collectionKey);
            await client.Activate(TestData.ProjectId, collection.Id, true);

            //then
            var result = await client.GetOne(TestData.ProjectId, collectionKey: collectionKey);

            //then
            result.ShouldNotBeNull();
            result.Status.ShouldEqual(CollectionStatus.Active);
            result.Key.ShouldEqual(collectionKey);
            result.Description.ShouldBeNull();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
        public async Task DeleteTag_MultipleTagVersion_ByCollectionKey_WithWeightAndRemoveOther(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            const string collectionKey = "qwert";
            var tags = new[] { "abc", "def", "ghi" };

            var collection =
                await client.New(TestData.ProjectId, collectionName, collectionKey);
            await client.Activate(TestData.ProjectId, collection.Id, true);

            var tagRequest = new ManageCollactionTagsRequest();
            tagRequest.ProjectId = TestData.ProjectId;
            tagRequest.Tags = new List<string>(tags);
            tagRequest.CollectionKey = collectionKey;

            await client.AddTag(tagRequest, 10.84, true);

            //when
            var result = await client.DeleteTag(tagRequest);
            var request = new GetCollectionRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tag = tags[0];
            var array = await client.Get(request);

            //then
            result.ShouldBeTrue();
            array.ShouldBeEmpty();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
        public async Task DeleteTag_SingleTagVersion_ByCollectionKey_WithWeightAndRemoveOther(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            string collectionKey = "qwert";
            string tag = "abcde";

            var collection =
                await client.New(TestData.ProjectId, collectionName, collectionKey);
            await client.Activate(TestData.ProjectId, collection.Id);

            var request = new ManageCollactionTagsRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tag = tag;
            request.CollectionKey = collectionKey;

            await client.AddTag(request, 3.5, true);

            //when
            var result = await client.DeleteTag(request);

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }