コード例 #1
0
        public async Task DetectedLanguageNullIso6391Name()
        {
            using var stream = new MemoryStream(Encoding.UTF8.GetBytes(@"
                {
                    ""kind"": ""LanguageDetectionResults"",
                    ""results"": {
                        ""documents"": [
                        {
                            ""id"": ""1"",
                            ""detectedLanguage"": {
                                ""name"": ""English"",
                                ""iso6391Name"": null,
                                ""confidenceScore"": 1
                                },
                                ""warnings"": []
                            }
                        ],
                        ""errors"": [],
                        ""modelVersion"": ""2020 -07-01""
                    }
                }"));

            var mockResponse = new MockResponse(200);

            mockResponse.ContentStream = stream;

            var mockTransport = new MockTransport(new[] { mockResponse });
            var client        = CreateTestClient(mockTransport);

            var documents = new List <DetectLanguageInput>
            {
                new DetectLanguageInput("1", "Hello world")
                {
                    CountryHint = "us",
                }
            };

            DetectLanguageResultCollection response = await client.DetectLanguageBatchAsync(documents);

            Assert.IsNotNull(response.FirstOrDefault().PrimaryLanguage.Name);
            Assert.IsNull(response.FirstOrDefault().PrimaryLanguage.Iso6391Name);
        }