Skip to content

Commit a55c504

Browse files
committed
reformat
1 parent c17fe04 commit a55c504

File tree

8 files changed

+49
-42
lines changed

8 files changed

+49
-42
lines changed

Modrinth.Net.Test/FacetCollectionTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Modrinth.Models.Facets;
2-
using Newtonsoft.Json;
32

43
namespace Modrinth.Net.Test;
54

@@ -13,15 +12,15 @@ public void CollectionWithOnlyOneFacet()
1312
collection.Add(Facet.Category("test"));
1413
Assert.That(collection.ToString(), Is.EqualTo("[[\"categories:test\"]]"));
1514
}
16-
15+
1716
[Test]
1817
public void CollectionWithMultipleFacets_OR()
1918
{
2019
var collection = new FacetCollection();
2120
collection.Add(Facet.Category("test"), Facet.Category("test2"));
2221
Assert.That(collection.ToString(), Is.EqualTo("[[\"categories:test\",\"categories:test2\"]]"));
2322
}
24-
23+
2524
[Test]
2625
public void CollectionWithMultipleFacets_AND()
2726
{
@@ -30,13 +29,14 @@ public void CollectionWithMultipleFacets_AND()
3029
collection.Add(Facet.Category("test2"));
3130
Assert.That(collection.ToString(), Is.EqualTo("[[\"categories:test\"],[\"categories:test2\"]]"));
3231
}
33-
32+
3433
[Test]
3534
public void CollectionWithMultipleFacets_AND_OR()
3635
{
3736
var collection = new FacetCollection();
3837
collection.Add(Facet.Category("test"));
3938
collection.Add(Facet.Category("test2"), Facet.Category("test3"));
40-
Assert.That(collection.ToString(), Is.EqualTo("[[\"categories:test\"],[\"categories:test2\",\"categories:test3\"]]"));
39+
Assert.That(collection.ToString(),
40+
Is.EqualTo("[[\"categories:test\"],[\"categories:test2\",\"categories:test3\"]]"));
4141
}
4242
}

Modrinth.Net.Test/Modrinth.Net.Test.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Flurl" Version="3.0.7" />
13-
<PackageReference Include="Flurl.Http" Version="3.2.4" />
14-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
15-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
17-
<PackageReference Include="NUnit" Version="3.13.3" />
18-
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
12+
<PackageReference Include="Flurl" Version="3.0.7"/>
13+
<PackageReference Include="Flurl.Http" Version="3.2.4"/>
14+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0"/>
15+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0"/>
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1"/>
17+
<PackageReference Include="NUnit" Version="3.13.3"/>
18+
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1"/>
1919
<PackageReference Include="NUnit.Analyzers" Version="3.5.0">
2020
<PrivateAssets>all</PrivateAssets>
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -27,11 +27,11 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<ProjectReference Include="..\Modrinth.Net\Modrinth.Net.csproj" />
30+
<ProjectReference Include="..\Modrinth.Net\Modrinth.Net.csproj"/>
3131
</ItemGroup>
3232

3333
<ItemGroup>
34-
<None Include="appsettings.json" CopyToOutputDirectory="Always" />
34+
<None Include="appsettings.json" CopyToOutputDirectory="Always"/>
3535
</ItemGroup>
3636

3737
</Project>

Modrinth.Net.Test/ModrinthApiTests/SearchTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,17 @@ public async Task Search_WithUpdatedSort_ShouldReturnSortedByUpdatedList()
126126
search.Hits.Select(p => p.DateModified),
127127
Is.EqualTo(search.Hits.Select(p => p.DateModified).OrderByDescending(d => d)));
128128
}
129-
129+
130130
// Search with facets
131131
[Test]
132132
public async Task Search_WithFacets_ShouldReturnFilteredResults()
133133
{
134134
var facets = new FacetCollection();
135-
135+
136136
facets.Add(Facet.Category("adventure"));
137-
137+
138138
var search = await _client.Project.SearchAsync("", facets: facets);
139-
139+
140140
// Check that every search result has the adventure category
141141
Assert.That(search.Hits.Select(p => p.Categories).All(c => c.Contains("adventure")));
142142
}

Modrinth.Net/Endpoints/Project/ProjectApi.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ public async Task<SearchResponse> SearchAsync(string query, Index index = Index.
7272
.SetQueryParam("index", index.ToString().ToLower())
7373
.SetQueryParam("offset", offset)
7474
.SetQueryParam("limit", limit);
75-
76-
if (facets is {Count: > 0})
77-
{
78-
request = request.SetQueryParam("facets", facets.ToString());
79-
}
80-
75+
76+
if (facets is {Count: > 0}) request = request.SetQueryParam("facets", facets.ToString());
77+
8178
return await request.GetJsonAsync<SearchResponse>();
8279
}
8380
}

Modrinth.Net/Helpers/UrlCreatorHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public static class UrlCreatorHelper
1313
/// </summary>
1414
public const string ModrinthUrl = "https://modrinth.com";
1515

16-
1716

1817
/// <summary>
1918
/// Return direct link to the user on Modrinth

Modrinth.Net/Models/Facets/Facet.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,38 @@ namespace Modrinth.Models.Facets;
55

66
public abstract class Facet
77
{
8-
public static Facet<string> Category(string value) => new (FacetType.Categories, value);
9-
10-
public static Facet<string> Version(string value) => new(FacetType.Versions, value);
11-
12-
public static Facet<string> License(string value) => new(FacetType.License, value);
13-
14-
public static Facet<string> ProjectType(ProjectType projectType) => new(FacetType.ProjectType, projectType.ToModrinthString());
8+
public static Facet<string> Category(string value)
9+
{
10+
return new(FacetType.Categories, value);
11+
}
12+
13+
public static Facet<string> Version(string value)
14+
{
15+
return new(FacetType.Versions, value);
16+
}
17+
18+
public static Facet<string> License(string value)
19+
{
20+
return new(FacetType.License, value);
21+
}
22+
23+
public static Facet<string> ProjectType(ProjectType projectType)
24+
{
25+
return new(FacetType.ProjectType, projectType.ToModrinthString());
26+
}
1527
}
1628

1729
public class Facet<T> : Facet
1830
{
19-
public FacetType Type { get; }
20-
public T Value { get; }
21-
2231
public Facet(FacetType type, T value)
2332
{
2433
Type = type;
2534
Value = value;
2635
}
2736

37+
public FacetType Type { get; }
38+
public T Value { get; }
39+
2840
public override string ToString()
2941
{
3042
return Type switch

Modrinth.Net/Models/Facets/FacetCollection.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ namespace Modrinth.Models.Facets;
22

33
public class FacetCollection
44
{
5-
public int Count => _facets.Count;
6-
75
private readonly List<Facet[]> _facets = new();
6+
public int Count => _facets.Count;
87

98
/// <summary>
109
/// Adds a facets to the collection, it will be added as a new group
@@ -23,9 +22,9 @@ public override string ToString()
2322
{
2423
// Serialize the facets into a Javascript array
2524
var serializedFacets = _facets.Select(
26-
facets =>
25+
facets =>
2726
$"[{string.Join(',', facets.Select(facet => $"\"{facet}\""))}]");
28-
27+
2928
return $"[{string.Join(',', serializedFacets)}]";
3029
}
3130
}

Modrinth.Net/Modrinth.Net.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
</ItemGroup>
2626

2727
<ItemGroup>
28-
<PackageReference Include="Flurl" Version="3.0.7" />
29-
<PackageReference Include="Flurl.Http" Version="3.2.4" />
30-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
28+
<PackageReference Include="Flurl" Version="3.0.7"/>
29+
<PackageReference Include="Flurl.Http" Version="3.2.4"/>
30+
<PackageReference Include="Newtonsoft.Json" Version="13.0.2"/>
3131
</ItemGroup>
3232

3333
</Project>

0 commit comments

Comments
 (0)