Class with Collection management api.
 public async Task New_WithInvalidProjectId_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.New("abcde", "New collection name");
         throw new Exception("New should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
 public async Task New_WithNullProjectId_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.New(null, "New collection name");
         throw new Exception("New should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }
        public async Task New_WithoutKeyAndDescription_CreatesNewCollectionObject(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();

            //when
            var collection =
                await client.New(TestData.ProjectId, collectionName);

            //then
            collection.ShouldNotBeNull();
            collection.Status.ShouldEqual(CollectionStatus.Inactive);
            collection.Key.ShouldBeNull();
            collection.Description.ShouldBeNull();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
 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 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 Authorize_WithNullIdAndKey_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await
             client.Authorize(TestData.UserApiClientId, Permissions.DeleteOwnData,
                 TestData.ProjectId);
         throw new Exception("Authorize should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }
        public async Task AddTag_MultipleTagVersion_NoTags_ThrowsException(CollectionSyncanoClient client)
        {
            //given
            var request = new ManageCollactionTagsRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionKey = TestData.CollectionKey;

            try
            {
                //when
                await
                    client.AddTag(request, 10.84, true);
                throw new Exception("AddTag should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentException>();
            }
        }
        public async Task Update_ByCollectionId_WithoutNameAndDescription(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);

            //when
            collection =
                await
                    client.Update(TestData.ProjectId, collection.Id);

            //then
            collection.ShouldNotBeNull();
            collection.Key.ShouldEqual(collectionKey);

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
 public async Task Update_WithNullProjectIdId_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.Update(null, TestData.CollectionId);
         throw new Exception("Update should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }
 public async Task Deactivate_WithNullIdAndKey_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.Deactivate(TestData.ProjectId);
         throw new Exception("Deactivate should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }
        public async Task DeleteTag_SingleTagVersion_WithInvalidCollectionKey_ThrowsException(CollectionSyncanoClient client)
        {
            //given
            var request = new ManageCollactionTagsRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tag = "tag";
            request.CollectionKey = "abcde";

            try
            {
                //when
                await client.DeleteTag(request);

                throw new Exception("DeleteTag should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<SyncanoException>();
            }
        }
        public async Task DeleteTag_MultipleTagVersion_WithEmptyTags_ThrowsException(CollectionSyncanoClient client)
        {
            //given
            var tagRequest = new ManageCollactionTagsRequest();
            tagRequest.ProjectId = TestData.ProjectId;
            tagRequest.CollectionId = TestData.CollectionId;
            tagRequest.Tags = new List<string>();

            try
            {
                //when
                await client.DeleteTag(tagRequest);
                throw new Exception("DeleteTag should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentException>();
            }
        }
        public async Task Get_MultipleTagVersion_WithTagsAndTag(CollectionSyncanoClient client)
        {
            //given
            var tags = new List<string> { "abc", "def", "ghi", "jkl" };
            var collection = await client.New(TestData.ProjectId, "Get test");
            var tagRequest = new ManageCollactionTagsRequest();
            tagRequest.ProjectId = TestData.ProjectId;
            tagRequest.Tags = tags;
            tagRequest.CollectionId = collection.Id;
            await client.AddTag(tagRequest);
            var request = new GetCollectionRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tags = new List<string> {tags[0], tags[1], tags[2]};
            request.Tag = tags[3];
            request.Status = CollectionStatus.Inactive;

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

            //then
            result.ShouldNotBeEmpty();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
        public async Task DeleteTag_MultipleTagVersion_WithInvalidProjectId_ThrowsException(CollectionSyncanoClient client)
        {
            //given
            var tags = new[] { "abc", "def", "ghi" };
            var tagRequest = new ManageCollactionTagsRequest();
            tagRequest.ProjectId = "abcde";
            tagRequest.Tags = new List<string>(tags);
            tagRequest.CollectionId = TestData.CollectionId;

            try
            {
                //when
                await client.DeleteTag(tagRequest);
                throw new Exception("DeleteTag should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<SyncanoException>();
            }
        }
        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_WithNullTag_ThrowsException(CollectionSyncanoClient client)
        {
            //given
            var request = new ManageCollactionTagsRequest();
            request.ProjectId = TestData.ProjectId;
            request.CollectionId = TestData.CollectionId;
            request.Tag = null;

            try
            {
                //when
                await client.DeleteTag(request);
                throw new Exception("DeleteTag should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentException>();
            }
        }
        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 AddTag_RemoveOtherTest(CollectionSyncanoClient client)
        {
            //given
            string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " +
                                    DateTime.Now.ToShortDateString();
            const string collectionKey = "qwert";
            var tags = new[] { "abc", "def", "ghi" };
            var tag = "jkl";

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

            var tagRequest = new ManageCollactionTagsRequest();
            tagRequest.ProjectId = TestData.ProjectId;
            tagRequest.CollectionId = collection.Id;
            tagRequest.Tag = tag;
            await client.AddTag(tagRequest);

            tagRequest.Tags = new List<string>(tags);
            tagRequest.Tag = null;

            //when
            var result = await client.AddTag(tagRequest, 10.84, true);
            var request = new GetCollectionRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tags = new List<string>(tags);
            var array = await client.Get(request);

            //then
            result.ShouldBeTrue();
            array.ShouldNotBeEmpty();
            array.Any(c => c.Tags.Count == tags.Length).ShouldBeTrue();

            //cleanup
            await client.Delete(TestData.ProjectId, collection.Id);
        }
        public async Task Get_MultipleTagVersion_WithEmptyTags(CollectionSyncanoClient client)
        {
            //given
            //given
            var tags = new List<string>();
            var collection = await client.New(TestData.ProjectId, "Get test");
            var request = new GetCollectionRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tags = tags;
            
            //when
            var result = await client.Get(request);
            
            //then
            result.ShouldNotBeEmpty();
            result.Any(c => c.Id == collection.Id).ShouldBeTrue();

            //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);
        }
 public async Task Deactivate_WithInvalidCollectionKey_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.Deactivate(TestData.ProjectId, collectionKey: "abcde");
         throw new Exception("Deactivate should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
        public async Task Get_WithNullProjectId_ThrowsException(CollectionSyncanoClient client)
        {
            //given
            var request = new GetCollectionRequest();
            request.ProjectId = null;

            try
            {
                //when
                await client.Get(request);
                throw new Exception("Get should throw an exception");
            }
            catch (Exception e)
            {
                //then
                e.ShouldBeType<ArgumentNullException>();
            }
        }
        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 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 Update_WithInvalidProjectIdId_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.Update("abcde", TestData.CollectionId);
         throw new Exception("Update should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
 public async Task GetOne_NullProjectId(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.GetOne(null, TestData.CollectionId);
         throw new Exception("GetOne should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }
        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 GetOne_InvalidProjectId(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await client.GetOne("abcde", TestData.CollectionId);
         throw new Exception("GetOne should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
 public async Task Authorize_WithInvalidCollectionKey_ThrowsException(CollectionSyncanoClient client)
 {
     try
     {
         //when
         await
             client.Authorize(TestData.UserApiClientId, Permissions.DeleteOwnData,
                 TestData.ProjectId, collectionKey: "abcde");
         throw new Exception("Authorize should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
        public async Task Get_OneTagVersion_WithTagAndStatus(CollectionSyncanoClient client)
        {
            //given
            string tag = "qwert";
            var collection = await client.New(TestData.ProjectId, "Get test");
            var tagRequest = new ManageCollactionTagsRequest();
            tagRequest.ProjectId = TestData.ProjectId;
            tagRequest.Tag = tag;
            tagRequest.CollectionId = collection.Id;
            await client.AddTag(tagRequest);
            var request = new GetCollectionRequest();
            request.ProjectId = TestData.ProjectId;
            request.Tag = tag;
            request.Status = CollectionStatus.Inactive;

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

            //then
            result.ShouldNotBeEmpty();

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