/// <summary> /// Get collections by a specified request. /// </summary> /// <param name="request">Query request.</param> /// <returns>List of Collection objects.</returns> public async Task<List<Collection>> Get(GetCollectionRequest request) { if(request.ProjectId == null) throw new ArgumentNullException(); var withTags = request.Tags == null ? new List<string>() : new List<string>(request.Tags); if(request.Tag != null) withTags.Add(request.Tag); var withTagsArray = withTags.Count == 0 ? null : withTags.ToArray(); return await _syncanoClient.PostAsync<List<Collection>>("collection.get", new {project_id = request.ProjectId, status = request.Status.ToString(), with_tags = withTagsArray}, "collection"); }
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 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 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_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 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_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); }
public async Task Get_NoTagVersion_WithInctiveStatus(CollectionSyncanoClient client) { //given var collection = await client.New(TestData.ProjectId, "Get test"); var request = new GetCollectionRequest(); request.ProjectId = TestData.ProjectId; request.Status = CollectionStatus.Inactive; //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 Get_NoTagVersion_WitActiveStatus(CollectionSyncanoClient client) { //given var request = new GetCollectionRequest(); request.ProjectId = TestData.ProjectId; request.Status = CollectionStatus.Active; //when var result = await client.Get(request); //then result.ShouldNotBeEmpty(); result.Any(c => c.Id == TestData.CollectionId).ShouldBeTrue(); }
public async Task Get_NoTagVersion_WithoutStatus(CollectionSyncanoClient client) { //given var request = new GetCollectionRequest(); request.ProjectId = TestData.ProjectId; //when var result = await client.Get(request); //then result.ShouldNotBeEmpty(); }