Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Content Safety by way of the content_filter query parameter #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion UnsplashsharpTest/PhotoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,20 @@ public async Task GetPhotoTest() {
}

[TestMethod]
public async Task GetRandomPhotoTest() {
public async Task GetRandomPhotoTestLowSafety()
{
await GetRandomPhotoTest(UnsplasharpClient.ContentSafety.Low);
}

[TestMethod]
public async Task GetRandomPhotoTestHighSafety()
{
await GetRandomPhotoTest(UnsplasharpClient.ContentSafety.High);
}

private async Task GetRandomPhotoTest(UnsplasharpClient.ContentSafety contentFilter) {
var client = new UnsplasharpClient(Credentials.ApplicationId);
client.ContentFilter = contentFilter;
var randomPhoto = await client.GetRandomPhoto();

var randomPhotoFromCollection = await client.GetRandomPhoto("499830");
Expand Down
14 changes: 13 additions & 1 deletion UnsplashsharpTest/SearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,21 @@ namespace UnsplashsharpTest {
[TestClass]
public class SearchTests {
[TestMethod]
public async Task SearchPhotosTest() {
public async Task SearchPhotosTestLowSafety()
{
await SearchPhotosTest(UnsplasharpClient.ContentSafety.Low);
}

[TestMethod]
public async Task SearchPhotosTestHighSafety()
{
await SearchPhotosTest(UnsplasharpClient.ContentSafety.High);
}

private async Task SearchPhotosTest(UnsplasharpClient.ContentSafety contentFilter) {
var query = "mountains";
var client = new UnsplasharpClient(Credentials.ApplicationId);
client.ContentFilter = contentFilter;
var photosFound = await client.SearchPhotos(query);
var photosFoundPaged = await client.SearchPhotos(query, 2);

Expand Down
1 change: 1 addition & 0 deletions UnsplashsharpTest/UnsplashsharpTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Loading