-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c64893c
commit ba15862
Showing
41 changed files
with
5,740 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...rch/BingNewsSearch.Tests/Microsoft.Azure.CognitiveServices.Search.NewsSearch.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" /> | ||
<PropertyGroup> | ||
<Description>Microsoft.Azure.CognitiveServices.Search.NewsSearch.Tests Class Library</Description> | ||
<AssemblyName>Microsoft.Azure.CognitiveServices.Search.NewsSearch.Tests</AssemblyName> | ||
<VersionPrefix>1.1.0-preview</VersionPrefix> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp1.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" /> | ||
<ProjectReference Include="..\BingNewsSearch\Microsoft.Azure.CognitiveServices.Search.NewsSearch.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="SessionRecords\**\*.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> | ||
</ItemGroup> | ||
|
||
</Project> |
91 changes: 91 additions & 0 deletions
91
...CognitiveServices/dataPlane/Search/BingNewsSearch/BingNewsSearch.Tests/NewsSearchTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using Microsoft.Azure.Test.HttpRecorder; | ||
using Microsoft.Azure.CognitiveServices.Search.NewsSearch; | ||
using Microsoft.Azure.CognitiveServices.Search.NewsSearch.Models; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace SearchSDK.Tests | ||
{ | ||
public class NewsSearchTests | ||
{ | ||
private static string SubscriptionKey = "fake"; | ||
|
||
[Fact] | ||
public void NewsSearch() | ||
{ | ||
using (MockContext context = MockContext.Start(this.GetType().FullName)) | ||
{ | ||
HttpMockServer.Initialize(this.GetType().FullName, "NewsSearch"); | ||
|
||
INewsSearchAPI client = new NewsSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance()); | ||
|
||
var resp = client.News.SearchAsync(query: "tom cruise").Result; | ||
|
||
Assert.NotNull(resp); | ||
Assert.NotNull(resp.Value); | ||
Assert.True(resp.Value.Count > 0); | ||
|
||
var news = resp.Value[0]; | ||
Assert.NotNull(news.Name); | ||
Assert.NotNull(news.Url); | ||
Assert.NotNull(news.Description); | ||
Assert.NotNull(news.DatePublished); | ||
Assert.NotNull(news.Provider); | ||
Assert.NotNull(news.Provider[0].Name); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void NewsCategory() | ||
{ | ||
using (MockContext context = MockContext.Start(this.GetType().FullName)) | ||
{ | ||
HttpMockServer.Initialize(this.GetType().FullName, "NewsCategory"); | ||
|
||
INewsSearchAPI client = new NewsSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance()); | ||
|
||
var resp = client.News.CategoryAsync(category: "sports").Result; | ||
|
||
Assert.NotNull(resp); | ||
Assert.NotNull(resp.Value); | ||
Assert.True(resp.Value.Count > 0); | ||
|
||
var news = resp.Value[0]; | ||
Assert.NotNull(news.Name); | ||
Assert.NotNull(news.Url); | ||
Assert.NotNull(news.Description); | ||
Assert.NotNull(news.DatePublished); | ||
Assert.NotNull(news.Provider); | ||
Assert.NotNull(news.Category); | ||
Assert.NotNull(news.Provider[0].Name); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void NewsTrending() | ||
{ | ||
using (MockContext context = MockContext.Start(this.GetType().FullName)) | ||
{ | ||
HttpMockServer.Initialize(this.GetType().FullName, "NewsTrending"); | ||
|
||
INewsSearchAPI client = new NewsSearchAPI(new ApiKeyServiceClientCredentials(SubscriptionKey), HttpMockServer.CreateInstance()); | ||
|
||
var resp = client.News.TrendingAsync().Result; | ||
|
||
Assert.NotNull(resp); | ||
Assert.NotNull(resp.Value); | ||
Assert.True(resp.Value.Count > 0); | ||
|
||
var trendingTopic = resp.Value[0]; | ||
Assert.NotNull(trendingTopic.Name); | ||
Assert.NotNull(trendingTopic.WebSearchUrl); | ||
Assert.NotNull(trendingTopic.NewsSearchUrl); | ||
Assert.NotNull(trendingTopic.Image); | ||
Assert.NotNull(trendingTopic.Image.Url); | ||
Assert.NotNull(trendingTopic.Query); | ||
Assert.NotNull(trendingTopic.Query.Text); | ||
} | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...rch/BingNewsSearch.Tests/SessionRecords/SearchSDK.Tests.NewsSearchTests/NewsCategory.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"Entries": [ | ||
{ | ||
"RequestUri": "/bing/v7.0/news?category=sports", | ||
"RequestMethod": "GET", | ||
"RequestHeaders": { | ||
"User-Agent": [ | ||
"FxVersion/4.6.25211.01", | ||
"Microsoft.CognitiveServices.Vision.Face.FaceAPI/1.0.0" | ||
] | ||
}, | ||
"ResponseBody": "{\r\n\"_type\": \"News\",\r\n\"totalEstimatedMatches\": 46,\r\n\"value\": [{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"ZDNet\"\r\n }],\r\n \"datePublished\": \"2017-11-16T14:15:00Z\",\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"Surface Book 2 (15-inch): <b>Microsoft</b> supersizes its most powerful portable PC\",\r\n \"url\": \"http://www.zdnet.com/product/microsoft-surface-book-2/\",\r\n \"description\": \"Don't call it Surface Pro 5. The latest iteration of the Surface Pro loses the model number, keeps the kickstand, and adds mostly subtle refinements. Read More For the past five days, I've been using a Surface Book 2 in place of my everyday PC, a first ...\"\r\n},\r\n{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"CNET\"\r\n }],\r\n \"datePublished\": \"2017-11-17T06:13:00Z\",\r\n \"video\": {\r\n \"_type\": \"VideoObject\",\r\n \"name\": \"Microsoft Surface Book 2 (15-inch)\",\r\n \"thumbnailUrl\": \"https://www.bing.com/th?id=ON.C362047C8A293C48E4DBF9FCF1C99DD2&pid=News\",\r\n \"allowHttpsEmbed\": true,\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"width\": 480,\r\n \"height\": 269\r\n }\r\n },\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"<b>Microsoft</b> Surface Book 2 (15-inch) review:\",\r\n \"url\": \"https://www.cnet.com/products/microsoft-surface-book-2/review/\",\r\n \"description\": \"<b>Microsoft</b> Surface Book 2 - 15" - Core i7 8650U - 16 GB RAM - 512 GB SSD - English - North America fux00001 $2,899.00 <b>Microsoft</b> Surface Book 2 - 15" - Core i7 8650U - 16 GB RAM - 256 GB SSD - English - North America hnr00001 $2,499.00 <b>Microsoft</b> Surface Book ...\",\r\n \"image\": {\r\n \"_type\": \"ImageObject\",\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"contentUrl\": \"https://www.bing.com/th?id=ON.4A5C3F257DA120C0D7778A4A764A0292&pid=News\",\r\n \"width\": 700,\r\n \"height\": 393\r\n }\r\n }\r\n},\r\n{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"PC Magazine\"\r\n }],\r\n \"datePublished\": \"2017-11-17T04:27:00Z\",\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"12 Reasons <b>Microsoft</b>'s Edge Browser Rocks (No, Really)\",\r\n \"url\": \"https://www.pcmag.com/feature/357262/12-reasons-microsoft-s-edge-browser-rocks-no-really\",\r\n \"description\": \"At just two years old, Edge is the new kid on the web browser block, but what it lacks in maturity, it makes up for in speed and convenience. Development has been swift. With each major Windows 10 release, Edge improves. Windows 10 Fall Creators Update ...\",\r\n \"image\": {\r\n \"_type\": \"ImageObject\",\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"contentUrl\": \"https://www.bing.com/th?id=ON.D6CC6169ECD49465AACCC1327B37283E&pid=News\",\r\n \"width\": 700,\r\n \"height\": 394\r\n }\r\n }\r\n},\r\n{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"Business Insider\"\r\n }],\r\n \"datePublished\": \"2017-11-16T23:58:00Z\",\r\n \"clusteredArticles\": [{\r\n \"_type\": \"NewsArticle\",\r\n \"name\": \"REVIEW: <b>Microsoft</b>'s newest laptop is my new favorite computer (MSFT)\",\r\n \"url\": \"https://www.msn.com/en-us/money/other/review-microsofts-newest-laptop-is-my-new-favorite-computer-msft/ar-BBF2svf\",\r\n \"description\": \"It may have been the company's first-ever laptop, but when I tested it last year a few months after it debuted, I immediately liked it better than any of Apple's MacBooks that I'd ever used. I now have a new favorite computer, and it's the successor to my ...\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"Business Insider on MSN.com\"\r\n }],\r\n \"datePublished\": \"2017-11-17T01:59:00Z\",\r\n \"category\": \"ScienceAndTechnology\"\r\n }],\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"REVIEW: <b>Microsoft</b>'s newest laptop is a powerful alternative to any of Apple's MacBooks or iPads\",\r\n \"url\": \"http://www.businessinsider.com/microsoft-surface-book-2-review-2017-11\",\r\n \"description\": \"<b>Microsoft</b>'s original Surface Book was my favorite computer. It may have been the company's first-ever laptop, but when I tested it last year a few months after it debuted, I immediately liked it better than any of Apple's MacBooks that I'd ever used.\",\r\n \"image\": {\r\n \"_type\": \"ImageObject\",\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"contentUrl\": \"https://www.bing.com/th?id=ON.7CEEFC996C222EA79BC65ABFE9356D63&pid=News\",\r\n \"width\": 700,\r\n \"height\": 524\r\n }\r\n }\r\n}]}", | ||
"ResponseHeaders": { | ||
"Content-Type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"Expires": [ | ||
"-1" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 30 Aug 2017 02:34:12 GMT" | ||
], | ||
"Pragma": [ | ||
"no-cache" | ||
], | ||
"X-AspNet-Version": [ | ||
"4.0.30319" | ||
], | ||
"X-Powered-By": [ | ||
"ASP.NET" | ||
], | ||
"apim-request-id": [ | ||
"2c1699ea-16ef-4ab2-a3ba-05c35aa3c1a6" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains; preload" | ||
], | ||
"x-content-type-options": [ | ||
"nosniff" | ||
] | ||
}, | ||
"StatusCode": 200 | ||
} | ||
], | ||
"Names": {}, | ||
"Variables": {} | ||
} |
50 changes: 50 additions & 0 deletions
50
...earch/BingNewsSearch.Tests/SessionRecords/SearchSDK.Tests.NewsSearchTests/NewsSearch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"Entries": [ | ||
{ | ||
"RequestUri": "/bing/v7.0/news/search?q=tom%20cruise", | ||
"RequestMethod": "GET", | ||
"RequestHeaders": { | ||
"User-Agent": [ | ||
"FxVersion/4.6.25211.01", | ||
"Microsoft.CognitiveServices.Vision.Face.FaceAPI/1.0.0" | ||
] | ||
}, | ||
"ResponseBody": "{\r\n\"_type\": \"News\",\r\n\"totalEstimatedMatches\": 46,\r\n\"value\": [{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"ZDNet\"\r\n }],\r\n \"datePublished\": \"2017-11-16T14:15:00Z\",\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"Surface Book 2 (15-inch): <b>Microsoft</b> supersizes its most powerful portable PC\",\r\n \"url\": \"http://www.zdnet.com/product/microsoft-surface-book-2/\",\r\n \"description\": \"Don't call it Surface Pro 5. The latest iteration of the Surface Pro loses the model number, keeps the kickstand, and adds mostly subtle refinements. Read More For the past five days, I've been using a Surface Book 2 in place of my everyday PC, a first ...\"\r\n},\r\n{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"CNET\"\r\n }],\r\n \"datePublished\": \"2017-11-17T06:13:00Z\",\r\n \"video\": {\r\n \"_type\": \"VideoObject\",\r\n \"name\": \"Microsoft Surface Book 2 (15-inch)\",\r\n \"thumbnailUrl\": \"https://www.bing.com/th?id=ON.C362047C8A293C48E4DBF9FCF1C99DD2&pid=News\",\r\n \"allowHttpsEmbed\": true,\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"width\": 480,\r\n \"height\": 269\r\n }\r\n },\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"<b>Microsoft</b> Surface Book 2 (15-inch) review:\",\r\n \"url\": \"https://www.cnet.com/products/microsoft-surface-book-2/review/\",\r\n \"description\": \"<b>Microsoft</b> Surface Book 2 - 15" - Core i7 8650U - 16 GB RAM - 512 GB SSD - English - North America fux00001 $2,899.00 <b>Microsoft</b> Surface Book 2 - 15" - Core i7 8650U - 16 GB RAM - 256 GB SSD - English - North America hnr00001 $2,499.00 <b>Microsoft</b> Surface Book ...\",\r\n \"image\": {\r\n \"_type\": \"ImageObject\",\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"contentUrl\": \"https://www.bing.com/th?id=ON.4A5C3F257DA120C0D7778A4A764A0292&pid=News\",\r\n \"width\": 700,\r\n \"height\": 393\r\n }\r\n }\r\n},\r\n{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"PC Magazine\"\r\n }],\r\n \"datePublished\": \"2017-11-17T04:27:00Z\",\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"12 Reasons <b>Microsoft</b>'s Edge Browser Rocks (No, Really)\",\r\n \"url\": \"https://www.pcmag.com/feature/357262/12-reasons-microsoft-s-edge-browser-rocks-no-really\",\r\n \"description\": \"At just two years old, Edge is the new kid on the web browser block, but what it lacks in maturity, it makes up for in speed and convenience. Development has been swift. With each major Windows 10 release, Edge improves. Windows 10 Fall Creators Update ...\",\r\n \"image\": {\r\n \"_type\": \"ImageObject\",\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"contentUrl\": \"https://www.bing.com/th?id=ON.D6CC6169ECD49465AACCC1327B37283E&pid=News\",\r\n \"width\": 700,\r\n \"height\": 394\r\n }\r\n }\r\n},\r\n{\r\n \"_type\": \"NewsArticle\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"Business Insider\"\r\n }],\r\n \"datePublished\": \"2017-11-16T23:58:00Z\",\r\n \"clusteredArticles\": [{\r\n \"_type\": \"NewsArticle\",\r\n \"name\": \"REVIEW: <b>Microsoft</b>'s newest laptop is my new favorite computer (MSFT)\",\r\n \"url\": \"https://www.msn.com/en-us/money/other/review-microsofts-newest-laptop-is-my-new-favorite-computer-msft/ar-BBF2svf\",\r\n \"description\": \"It may have been the company's first-ever laptop, but when I tested it last year a few months after it debuted, I immediately liked it better than any of Apple's MacBooks that I'd ever used. I now have a new favorite computer, and it's the successor to my ...\",\r\n \"provider\": [{\r\n \"_type\": \"Organization\",\r\n \"name\": \"Business Insider on MSN.com\"\r\n }],\r\n \"datePublished\": \"2017-11-17T01:59:00Z\",\r\n \"category\": \"ScienceAndTechnology\"\r\n }],\r\n \"category\": \"ScienceAndTechnology\",\r\n \"name\": \"REVIEW: <b>Microsoft</b>'s newest laptop is a powerful alternative to any of Apple's MacBooks or iPads\",\r\n \"url\": \"http://www.businessinsider.com/microsoft-surface-book-2-review-2017-11\",\r\n \"description\": \"<b>Microsoft</b>'s original Surface Book was my favorite computer. It may have been the company's first-ever laptop, but when I tested it last year a few months after it debuted, I immediately liked it better than any of Apple's MacBooks that I'd ever used.\",\r\n \"image\": {\r\n \"_type\": \"ImageObject\",\r\n \"thumbnail\": {\r\n \"_type\": \"ImageObject\",\r\n \"contentUrl\": \"https://www.bing.com/th?id=ON.7CEEFC996C222EA79BC65ABFE9356D63&pid=News\",\r\n \"width\": 700,\r\n \"height\": 524\r\n }\r\n }\r\n}]}", | ||
"ResponseHeaders": { | ||
"Content-Type": [ | ||
"application/json; charset=utf-8" | ||
], | ||
"Expires": [ | ||
"-1" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 30 Aug 2017 02:34:12 GMT" | ||
], | ||
"Pragma": [ | ||
"no-cache" | ||
], | ||
"X-AspNet-Version": [ | ||
"4.0.30319" | ||
], | ||
"X-Powered-By": [ | ||
"ASP.NET" | ||
], | ||
"apim-request-id": [ | ||
"2c1699ea-16ef-4ab2-a3ba-05c35aa3c1a6" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains; preload" | ||
], | ||
"x-content-type-options": [ | ||
"nosniff" | ||
] | ||
}, | ||
"StatusCode": 200 | ||
} | ||
], | ||
"Names": {}, | ||
"Variables": {} | ||
} |
Oops, something went wrong.