|
| 1 | +using ScriptBloxApi.Objects; |
| 2 | +using ScriptBloxApi.Scripts; |
| 3 | + |
| 4 | +namespace ScriptBloxAPI.Tests |
| 5 | +{ |
| 6 | + public class ScriptsTests |
| 7 | + { |
| 8 | + |
| 9 | + [Theory] |
| 10 | + // Basic default call |
| 11 | + [InlineData(1, 10, null, null, null, null, null, null, null)] |
| 12 | + |
| 13 | + // Free scripts, sorted by views descending |
| 14 | + [InlineData(1, 5, (int)Scripts.ScriptCost.free, true, null, null, null, (int)Scripts.SortBy.views, (int)Scripts.Order.desc)] |
| 15 | + |
| 16 | + // Paid scripts, filtered by key + verified |
| 17 | + [InlineData(2, 15, (int)Scripts.ScriptCost.paid, false, true, true, true, (int)Scripts.SortBy.likeCount, (int)Scripts.Order.asc)] |
| 18 | + |
| 19 | + // Universal only, sorted by updatedAt |
| 20 | + [InlineData(1, 20, null, null, null, true, null, (int)Scripts.SortBy.updatedAt, (int)Scripts.Order.desc)] |
| 21 | + |
| 22 | + // Verified scripts, sorted by createdAt ascending |
| 23 | + [InlineData(3, 7, null, null, null, null, true, (int)Scripts.SortBy.createdAt, (int)Scripts.Order.asc)] |
| 24 | + |
| 25 | + // Filtered by dislike count (low value edge case for page/max) |
| 26 | + [InlineData(1, 1, null, null, null, null, null, (int)Scripts.SortBy.dislikeCount, (int)Scripts.Order.desc)] |
| 27 | + public async Task FetchScriptsAsync_WithVariants_ReturnsResults( |
| 28 | + int page, |
| 29 | + int max, |
| 30 | + int? mode, |
| 31 | + bool? patched, |
| 32 | + bool? key, |
| 33 | + bool? universal, |
| 34 | + bool? verified, |
| 35 | + int? sortBy, |
| 36 | + int? order |
| 37 | + ) |
| 38 | + { |
| 39 | + Results? result = await Scripts.FetchScriptsAsync( |
| 40 | + page: page, |
| 41 | + max: max, |
| 42 | + mode: mode.HasValue ? (Scripts.ScriptCost?)mode.Value : null, |
| 43 | + patched: patched, |
| 44 | + key: key, |
| 45 | + universal: universal, |
| 46 | + verified: verified, |
| 47 | + sortBy: sortBy.HasValue ? (Scripts.SortBy?)sortBy.Value : null, |
| 48 | + order: order.HasValue ? (Scripts.Order?)order.Value : null |
| 49 | + ); |
| 50 | + |
| 51 | + Assert.NotNull(result); |
| 52 | + Assert.IsType<Results>(result); |
| 53 | + Assert.True(result.Scripts?.Count >= 0); // May be empty, but should be valid |
| 54 | + } |
| 55 | + |
| 56 | + [Fact] |
| 57 | + public async Task FetchScriptAsync_ReturnsScriptData() |
| 58 | + { |
| 59 | + ScriptData? script = await Scripts.FetchScriptAsync("61abb678404510c9285337ec"); // https://scriptblox.com/script/GUI_57 |
| 60 | + Assert.NotNull(script); |
| 61 | + Assert.IsType<ScriptData>(script); |
| 62 | + } |
| 63 | + |
| 64 | + [Fact] |
| 65 | + public async Task FetchTrendingScriptsAsync_ReturnsList() |
| 66 | + { |
| 67 | + IReadOnlyList<Script>? scripts = await Scripts.FetchTrendingScriptsAsync(); |
| 68 | + Assert.NotEmpty(scripts); |
| 69 | + } |
| 70 | + |
| 71 | + [Fact] |
| 72 | + public async Task SearchScriptsAsync_ReturnsResults() |
| 73 | + { |
| 74 | + Results? result = await Scripts.SearchScriptsAsync("Infinite Yield"); |
| 75 | + Assert.NotNull(result); |
| 76 | + Assert.IsType<Results>(result); |
| 77 | + } |
| 78 | + } |
| 79 | +} |
0 commit comments