public async Task SearchByConceptIDShouldBeSuccessful() { ClarifaiResponse <SearchInputsResult> response = await Client.SearchInputs(SearchBy.ConceptID("ai_mFqxrph2")) .ExecuteAsync(); AssertResponseSuccess(response); Assert.NotNull(response.Get().SearchHits); }
public async Task SearchByConceptNameWithLanguageShouldBeSuccessful() { ClarifaiResponse <List <IClarifaiInput> > addInputResponse = await Client.AddInputs( new ClarifaiURLImage( CAT1, positiveConcepts : new List <Concept> { new Concept("ネコ", "ネコ"), }, allowDuplicateUrl : true)) .ExecuteAsync(); AssertResponseSuccess(addInputResponse); string inputID = addInputResponse.Get()[0].ID; try { await WaitForSpecificInputsUpload(inputID); ClarifaiResponse <SearchInputsResult> response = await Client.SearchInputs(new List <SearchBy> { SearchBy.ConceptID("ネコ") // Cat in japanese. }, language : "jp") .ExecuteAsync(); AssertResponseSuccess(response); Assert.NotNull(response.Get().SearchHits); } finally { ClarifaiResponse <EmptyResponse> deleteInputResponse = await Client.DeleteInputs(inputID).ExecuteAsync(); AssertResponseSuccess(deleteInputResponse); } }
public async Task SearchInputsByIDRequestAndResponseShouldBeCorrect() { var httpClient = new FkClarifaiHttpClient( postResponse: @" { ""status"": { ""code"": 10000, ""description"": ""Ok"" }, ""hits"": [ { ""score"": 0.99, ""input"": { ""id"": ""@inputID"", ""created_at"": ""2016-11-22T17:06:02Z"", ""data"": { ""image"": { ""url"": ""@inputURL"" } }, ""status"": { ""code"": 30000, ""description"": ""Download complete"" } } } ] } "); var client = new ClarifaiClient(httpClient); var response = await client.SearchInputs(SearchBy.ConceptID("@conceptID")) .ExecuteAsync(); var expectedRequestBody = JObject.Parse(@" { ""query"": { ""ands"": [ { ""output"": { ""data"": { ""concepts"": [ { ""id"": ""@conceptID"" } ] } } } ] } } "); Assert.True(JToken.DeepEquals(expectedRequestBody, httpClient.PostedBody)); Assert.True(response.IsSuccessful); List <SearchHit> searchHits = response.Get().SearchHits; Assert.AreEqual(1, searchHits.Count); Assert.AreEqual("@inputID", searchHits[0].Input.ID); IClarifaiInput input = searchHits[0].Input; Assert.AreEqual(InputType.Image, input.Type); Assert.AreEqual(InputForm.URL, input.Form); ClarifaiURLImage image = (ClarifaiURLImage)input; Assert.AreEqual("@inputURL", image.URL); }