public void DeleteModel_No_Model_Id() { NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService("versionDate", new NoAuthAuthenticator()); service.DeleteModel(null); }
public void Constructor_HttpClient_Null() { NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(httpClient: null); }
public void Analyze_Success() { IClient client = CreateClient(); IRequest request = Substitute.For <IRequest>(); client.PostAsync(Arg.Any <string>()) .Returns(request); #region Response var response = new DetailedResponse <AnalysisResults>() { Result = new AnalysisResults() { Language = "en", AnalyzedText = "testText", RetrievedUrl = "retrivedUrl", Usage = new AnalysisResultsUsage() { Features = 1 }, Concepts = new List <ConceptsResult>() { new ConceptsResult() { Text = "text", Relevance = 1.0f, DbpediaResource = "dbpediaResouce" } }, Entities = new List <EntitiesResult>() { new EntitiesResult() { Type = "type", Relevance = 1.0f, Count = 1, Text = "text", Emotion = new EmotionScores() { Anger = 1.0f, Disgust = 1.0f, Fear = 1.0f, Joy = 1.0f, Sadness = 1.0f }, Sentiment = new FeatureSentimentResults() { Score = 1.0f }, Disambiguation = new DisambiguationResult() { Name = "name", DbpediaResource = "dbpediaResource", Subtype = new List <string>() { "subtype" } } } }, Keywords = new List <KeywordsResult>() { new KeywordsResult() { Relevance = 1.0f, Text = "text", Emotion = new EmotionScores() { Anger = 1.0f, Disgust = 1.0f, Fear = 1.0f, Joy = 1.0f, Sadness = 1.0f }, Sentiment = new FeatureSentimentResults() { Score = 1.0f } } }, Categories = new List <CategoriesResult>() { new CategoriesResult() { Label = "label", Score = 1.0f } }, Emotion = new EmotionResult() { Document = new DocumentEmotionResults() { Emotion = new EmotionScores() { Anger = 1.0f, Disgust = 1.0f, Fear = 1.0f, Joy = 1.0f, Sadness = 1.0f }, }, Targets = new List <TargetedEmotionResults>() { new TargetedEmotionResults() { Emotion = new EmotionScores() { Anger = 1.0f, Disgust = 1.0f, Fear = 1.0f, Joy = 1.0f, Sadness = 1.0f }, Text = "text" } } }, Metadata = new FeaturesResultsMetadata() { Authors = new List <Author>() { new Author() { Name = "name" } }, PublicationDate = "publicationDate", Title = "title" }, Relations = new List <RelationsResult>() { new RelationsResult() { Score = 1.0f, Sentence = "sentence", Type = "type", Arguments = new List <RelationArgument>() { new RelationArgument() { Entities = new List <RelationEntity>() { new RelationEntity() { Text = "text", Type = "type" } }, Text = "text" } } } }, SemanticRoles = new List <SemanticRolesResult>() { new SemanticRolesResult() { Sentence = "sentence", Subject = new SemanticRolesResultSubject() { Text = "text", Entities = new List <SemanticRolesEntity>() { new SemanticRolesEntity() { Text = "text", Type = "type" } }, Keywords = new List <SemanticRolesKeyword>() { new SemanticRolesKeyword() { Text = "text" } } }, Action = new SemanticRolesResultAction() { Normalized = "normalized", Text = "text", Verb = new SemanticRolesVerb() { Text = "text", Tense = "tense" } }, _Object = new SemanticRolesResultObject() { Text = "text", Keywords = new List <SemanticRolesKeyword>() { new SemanticRolesKeyword() { Text = "text" } } } } }, Sentiment = new SentimentResult() { Document = new DocumentSentimentResults() { Score = 1.0f }, Targets = new List <TargetedSentimentResults>() { new TargetedSentimentResults() { Score = 1.0f, Text = "text" } } } } }; #endregion request.WithArgument(Arg.Any <string>(), Arg.Any <string>()) .Returns(request); request.WithBodyContent(new StringContent("features")) .Returns(request); request.As <AnalysisResults>() .Returns(Task.FromResult(response)); NaturalLanguageUnderstandingService service = new NaturalLanguageUnderstandingService(client); service.Version = "versionDate"; var result = service.Analyze(new Features(), "testText", language: "en"); Assert.IsNotNull(result); client.Received().PostAsync(Arg.Any <string>()); Assert.IsTrue(result.Result.Language == "en"); Assert.IsTrue(result.Result.AnalyzedText == "testText"); }