Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Feb 26, 2024
1 parent 3819e5f commit f02bdd0
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
19 changes: 19 additions & 0 deletions FreePackages.Tests/Filters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,23 @@ public void CanFilterPackageByNoCost() {
Assert.IsFalse(PackageFilter.IsPackageIgnoredByFilter(no_cost_package, Filter));
Assert.IsTrue(PackageFilter.FilterOnlyAllowsPackages(Filter));
}

[TestMethod]
public void CanFilterByWishlist() {
var app = new FilterableApp(KeyValue.LoadAsText("app_which_is_free.txt"));

Assert.IsTrue(PackageFilter.IsAppWantedByFilter(app, Filter));

Filter.WishlistOnly = true;

Assert.IsFalse(PackageFilter.IsAppWantedByFilter(app, Filter));

PackageFilter.UpdateUserData(JsonConvert.DeserializeObject<UserData>(File.ReadAllText("userdata_with_wishlist_apps.json")));

Assert.IsTrue(PackageFilter.IsAppWantedByFilter(app, Filter));

PackageFilter.UpdateUserData(JsonConvert.DeserializeObject<UserData>(File.ReadAllText("userdata_with_followed_apps.json")));

Assert.IsTrue(PackageFilter.IsAppWantedByFilter(app, Filter));
}
}
29 changes: 29 additions & 0 deletions FreePackages.Tests/TestData/userdata_with_followed_apps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"rgWishlist":[],
"rgOwnedPackages":[],
"rgOwnedApps":[],
"rgFollowedApps":[440],
"rgMasterSubApps":[],
"rgPackagesInCart":[],
"rgAppsInCart":[],
"rgRecommendedTags":[],
"rgIgnoredApps":{},
"rgIgnoredPackages":[],
"rgCurators":{},
"rgCuratorsIgnored":[],
"rgCurations":{},
"bShowFilteredUserReviewScores":true,
"rgCreatorsFollowed":[],
"rgCreatorsIgnored":[],
"rgExcludedTags":[],
"rgExcludedContentDescriptorIDs":[],
"rgAutoGrantApps":[],
"rgRecommendedApps":[],
"rgPreferredPlatforms":[],
"rgPrimaryLanguage":null,
"rgSecondaryLanguages":[],
"bAllowAppImpressions":true,
"nCartLineItemCount":0,
"nRemainingCartDiscount":0,
"nTotalCartDiscount":0
}
29 changes: 29 additions & 0 deletions FreePackages.Tests/TestData/userdata_with_wishlist_apps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"rgWishlist":[440],
"rgOwnedPackages":[],
"rgOwnedApps":[],
"rgFollowedApps":[],
"rgMasterSubApps":[],
"rgPackagesInCart":[],
"rgAppsInCart":[],
"rgRecommendedTags":[],
"rgIgnoredApps":{},
"rgIgnoredPackages":[],
"rgCurators":{},
"rgCuratorsIgnored":[],
"rgCurations":{},
"bShowFilteredUserReviewScores":true,
"rgCreatorsFollowed":[],
"rgCreatorsIgnored":[],
"rgExcludedTags":[],
"rgExcludedContentDescriptorIDs":[],
"rgAutoGrantApps":[],
"rgRecommendedApps":[],
"rgPreferredPlatforms":[],
"rgPrimaryLanguage":null,
"rgSecondaryLanguages":[],
"bAllowAppImpressions":true,
"nCartLineItemCount":0,
"nRemainingCartDiscount":0,
"nTotalCartDiscount":0
}

0 comments on commit f02bdd0

Please sign in to comment.