Skip to content

Commit

Permalink
Merge pull request #79 from geefr/development
Browse files Browse the repository at this point in the history
Beataroni: List mods in alphabetic order
  • Loading branch information
geefr authored Jan 25, 2021
2 parents 3ea3017 + 40da9a4 commit fcbc813
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 2 additions & 8 deletions Beataroni/Beataroni.Tests/BeatModsV1Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void TestFetchBSVersions()
{
var versions = BeatModsV1.FetchBSVersions();
Assert.NotNull(versions);
Assert.Equal(11, versions.Count);
Assert.Equal(12, versions.Count);
}

[Fact]
Expand All @@ -22,13 +22,7 @@ public void TestFetchMods()

var mods = BeatModsV1.FetchMods(filters);
Assert.NotNull(mods);
Assert.Equal(56, mods.Count);
Assert.Equal(60, mods.Count);
}

// [Fact]
// public void TestInstallMod()
// {
// throw new NotImplementedException();
// }
}
}
7 changes: 7 additions & 0 deletions Beataroni/Beataroni/Models/BeatMods/mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ public static void GetDependencySet(Mod mod, ref HashSet<Mod> dependencies)
}
}

/// Comparator class for Mod
public class ModComparatorByName : IComparer<Mod>
{
public int Compare(Mod a, Mod b) => string.Compare(a.name, b.name, true);
}


/// <summary>
/// A Mod within Mod.dependencies
/// This is only a different class due to the way BeatMods returns dependencies
Expand Down
4 changes: 2 additions & 2 deletions Beataroni/Beataroni/Services/BeatModsV1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static IList<string> FetchBSVersions()

/// Fetch list of mods for a set of filters
/// Typical filters would be game version, installation type, mod status
public static IList<Mod> FetchMods( Dictionary<string, string> filters )
public static ICollection<Mod> FetchMods( Dictionary<string, string> filters )
{
var endpoint = $"{APIMod}";

Expand Down Expand Up @@ -90,7 +90,7 @@ public static IList<Mod> FetchMods( Dictionary<string, string> filters )
// Expand any dependencies into .net object references
mods.ForEach(x => x.ExpandDependencyRefs(mods));

return mods;
return new SortedSet<Mod>(mods, new ModComparatorByName());
} catch (WebException e)
{
Console.WriteLine($"Error fetching BS Mods: {e.Message}");
Expand Down

0 comments on commit fcbc813

Please sign in to comment.