public void HasMod_Enabled() { var listings = new ModListing[] { new ModListing(TestConstants.LightMasterModKey, true), new ModListing(TestConstants.LightMasterModKey2, false), new ModListing(TestConstants.LightMasterModKey3, true), }; listings .HasMod(TestConstants.LightMasterModKey, enabled: true) .Should().BeTrue(); listings .HasMod(TestConstants.LightMasterModKey, enabled: false) .Should().BeFalse(); listings .HasMod(TestConstants.LightMasterModKey2, enabled: false) .Should().BeTrue(); listings .HasMod(TestConstants.LightMasterModKey2, enabled: true) .Should().BeFalse(); listings .HasMod(TestConstants.LightMasterModKey3, enabled: true) .Should().BeTrue(); listings .HasMod(TestConstants.LightMasterModKey3, enabled: false) .Should().BeFalse(); }
public void HasMods_Enabled_Typical() { var listings = new ModListing[] { new ModListing(Utility.LightMasterModKey, true), new ModListing(Utility.LightMasterModKey2, false), new ModListing(Utility.LightMasterModKey3, true), }; listings .HasMods( true, Utility.LightMasterModKey, Utility.LightMasterModKey3) .Should().BeTrue(); listings .HasMods(false, Utility.LightMasterModKey2) .Should().BeTrue(); listings .HasMods( true, Utility.LightMasterModKey, Utility.LightMasterModKey2, Utility.LightMasterModKey3) .Should().BeFalse(); listings .HasMods( true, Utility.LightMasterModKey, Utility.LightMasterModKey2, Utility.LightMasterModKey4) .Should().BeFalse(); }
public void Enabled_Typical() { var listings = new ModListing[] { new ModListing(TestConstants.LightMasterModKey, true), new ModListing(TestConstants.LightMasterModKey2, false), new ModListing(TestConstants.LightMasterModKey3, true), }; listings .HasMods( true, TestConstants.LightMasterModKey, TestConstants.LightMasterModKey3) .Should().BeTrue(); listings .HasMods(false, TestConstants.LightMasterModKey2) .Should().BeTrue(); listings .HasMods( true, TestConstants.LightMasterModKey, TestConstants.LightMasterModKey2, TestConstants.LightMasterModKey3) .Should().BeFalse(); listings .HasMods( true, TestConstants.LightMasterModKey, TestConstants.LightMasterModKey2, TestConstants.LightMasterModKey4) .Should().BeFalse(); }
public void GetsListingsInitially( IScheduler scheduler, LiveLoadOrderProvider sut) { var listings = new ModListing[] { new ModListing(TestConstants.MasterModKey, true), new ModListing(TestConstants.MasterModKey2, false), }; sut.ListingsProvider.Get().Returns(listings); sut.PluginLive.Changed.Returns(Observable.Empty <Unit>()); sut.CccLive.Changed.Returns(Observable.Empty <Unit>()); var list = sut.Get(out var state, scheduler) .AsObservableList(); list.Items.Should().Equal(listings); sut.ListingsProvider.Received(1).Get(); var obsScheduler = new TestScheduler(); var err = obsScheduler.Start(() => state); err.ShouldHaveNoErrors(); err.ShouldNotBeCompleted(); err.Messages.Select(x => x.Value.Value.Succeeded).Should().AllBeEquivalentTo(true); }
public void Update() { _mirrorRegistry.Update(); var modListings = new List <ModListing>(); foreach (var mirror in _mirrorRegistry.Mirrors) { foreach (var mirrorListing in mirror.ModListings) { // If we already have a listing for this mod from another mirror if (modListings.Any(l => l.ModName == mirrorListing.ModName)) { // Update it if this mirror has a more recent version var match = modListings.Single(l => l.ModName == mirrorListing.ModName); if (modListings.Single(l => l.ModName == mirrorListing.ModName).LatestVersion.CompareTo(mirrorListing.LatestVersion) < 0) { match = new ModListing(match.ModName, mirrorListing.LatestVersionUrl); } } else { // Add the listing modListings.Add(mirrorListing); } } } ModListings = modListings; }
public void FileExists(Stream stream) { var scheduler = new TestScheduler(); var path = "C:/SomePath"; var listingA = new ModListing("ModA.esp", true); var fs = Substitute.For <IFileSystem>(); fs.File.OpenRead(path).Returns(stream); var reader = Substitute.For <ICreationClubRawListingsReader>(); reader.Read(Arg.Any <Stream>()).Returns(listingA.AsEnumerable()); var list = new CreationClubLiveListingsFileReader( fs, reader, new CreationClubListingsPathInjection(path)) .Get(out var state) .AsObservableList(); list.Items.Should().HaveCount(1); list.Items.First().Should().Be(listingA); var stateTest = scheduler.Start(() => state); stateTest.Messages.Should().HaveCount(1); stateTest.Messages[0].Value.Kind.Should().Be(NotificationKind.OnNext); stateTest.Messages[0].Value.Value.Succeeded.Should().BeTrue(); }
public void LoadOrderListingTests() { var listing1 = new ModListing(TestConstants.PluginModKey, enabled: true); var listing1Eq = new ModListing { ModKey = TestConstants.PluginModKey, Enabled = true, }; var listing1Disabled = new ModListing { ModKey = TestConstants.PluginModKey, Enabled = false, }; var listing2 = new ModListing(TestConstants.PluginModKey2, enabled: true); var listing2Eq = new ModListing() { ModKey = TestConstants.PluginModKey2, Enabled = true }; var listing2Disabled = new ModListing() { ModKey = TestConstants.PluginModKey2, Enabled = false }; listing1.Should().Be(listing1Eq); listing1.Should().NotBe(listing1Disabled); listing1.Should().NotBe(listing2); listing2.Should().Be(listing2Eq); listing2.Should().NotBe(listing2Disabled); listing2.Should().NotBe(listing1); }
public void FileIsCreated( [Frozen] FilePath path, [Frozen] MockFileSystemWatcher fileChanges, [Frozen] MockFileSystem fs) { var listingA = new ModListing("ModA.esp", true); var reader = Substitute.For <ICreationClubRawListingsReader>(); reader.Read(Arg.Any <Stream>()).Returns(listingA.AsEnumerable()); var list = new CreationClubLiveListingsFileReader( fs, reader, new CreationClubListingsPathInjection(path)) .Get(out var state) .AsObservableList(); list.Items.Should().HaveCount(0); var scheduler = new TestScheduler(); var stateTest = scheduler.Start(() => state); stateTest.Messages.Should().HaveCount(1); stateTest.Messages[0].Value.Kind.Should().Be(NotificationKind.OnNext); stateTest.Messages[0].Value.Value.Succeeded.Should().BeFalse(); fs.File.WriteAllText(path, string.Empty); fileChanges.MarkCreated(path); list.Items.Should().HaveCount(1); list.Items.First().Should().Be(listingA); stateTest = scheduler.Start(() => state); stateTest.Messages[^ 1].Value.Kind.Should().Be(NotificationKind.OnNext);
public void EnabledGhostProcessing() { var item = ModListing.FromString(Utility.PluginModKey.FileName, enabledMarkerProcessing: true); Assert.False(item.Enabled); Assert.Equal(Utility.PluginModKey, item.ModKey); item = ModListing.FromString($"*{Utility.PluginModKey.FileName}.ghost", enabledMarkerProcessing: true); Assert.False(item.Enabled); Assert.True(item.Ghosted); Assert.Equal(Utility.PluginModKey, item.ModKey); }
public void ParserResultsGetReturned( FilePath existingPath, PluginRawListingsReader sut) { var listings = new ModListing[] { new ModListing("ModA.esp", true), new ModListing("ModB.esp", false), }; sut.Parser.Parse(default !).ReturnsForAnyArgs(listings);
public void Add(IList <IModListingGetter> loadOrderListing) { var implicitlyAdded = _findImplicitlyIncludedMods.Find(loadOrderListing, skipMissingMods: true) .ToHashSet(); for (int i = loadOrderListing.Count - 1; i >= 0; i--) { var listing = loadOrderListing[i]; if (!listing.Enabled && implicitlyAdded.Contains(listing.ModKey)) { loadOrderListing[i] = new ModListing(listing.ModKey, enabled: true); } } }
public void Update() { _localRegistry.Update(); _remoteRegistry.Update(); var mods = new List <Mod>(); var installedMods = new List <ModConfiguration>(); foreach (var modInstallation in _localRegistry.ModInstallations) { installedMods.Add(modInstallation); } foreach (var modListing in _remoteRegistry.ModListings) { var installedMod = installedMods.FirstOrDefault(mod => mod.Name == modListing.ModName); if (installedMod != null) { mods.Add(new Mod(installedMod, modListing)); installedMods.Remove(installedMod); } else { mods.Add(new Mod(null, modListing)); } } try { // Specially load in AuroraLoader itself var auroraLoaderModInstallation = _localRegistry.ModInstallations.Single(i => i.Name == "AuroraLoader"); var auroraLoaderModListing = new ModListing(auroraLoaderModInstallation.Name, auroraLoaderModInstallation.Updates); mods.Add(new Mod(auroraLoaderModInstallation, auroraLoaderModListing)); installedMods.Remove(auroraLoaderModInstallation); } catch (Exception exc) { Log.Error($"Failed while loading AuroraLoader installation", exc); } // Handle mods we couldn't find a listing for in the registry foreach (var installedMod in installedMods) { mods.Add(new Mod(installedMod, null)); } Mods = mods; }
public void TrimsPastOutputPath( IEnumerable <IModListingGetter> listingsFirst, IEnumerable <IModListingGetter> listingsSecond, IReadOnlySet <ModKey> blacklist, ModPath outputPath, LoadOrderForRunProvider sut) { var modListingGetter = new ModListing(outputPath, true); sut.LoadOrderListingsProvider.Get(blacklist).Returns( listingsFirst .And(modListingGetter) .Concat(listingsSecond)); sut.Get(outputPath, blacklist) .Should().Equal(listingsFirst); }
public void Single() { var listings = new ModListing[] { new ModListing(TestConstants.LightMasterModKey, true), new ModListing(TestConstants.LightMasterModKey2, false), new ModListing(TestConstants.LightMasterModKey3, true), }; listings .HasMods(TestConstants.LightMasterModKey) .Should().BeTrue(); listings .HasMods(TestConstants.LightMasterModKey2) .Should().BeTrue(); listings .HasMods(TestConstants.LightMasterModKey3) .Should().BeTrue(); listings .HasMods(TestConstants.LightMasterModKey4) .Should().BeFalse(); }
public void HasMods_Single() { var listings = new ModListing[] { new ModListing(Utility.LightMasterModKey, true), new ModListing(Utility.LightMasterModKey2, false), new ModListing(Utility.LightMasterModKey3, true), }; listings .HasMods(Utility.LightMasterModKey) .Should().BeTrue(); listings .HasMods(Utility.LightMasterModKey2) .Should().BeTrue(); listings .HasMods(Utility.LightMasterModKey3) .Should().BeTrue(); listings .HasMods(Utility.LightMasterModKey4) .Should().BeFalse(); }
public void refreshList(int mods) { counter = 0; if (mods == 0) { ModListings.Clear(); ItemList.Controls.Clear(); WebClient web = new WebClient(); WebClient web2 = new WebClient(); DataContractJsonSerializer json1 = new DataContractJsonSerializer(typeof(JSONN)); JSONN jsonn = (JSONN)json1.ReadObject(new System.IO.MemoryStream(web.DownloadData("http://tldworkshop.hopto.org/modlist_2.json"))); download.Text = "Download"; mymods.Text = "My Mods"; string[] h = new string[] { "https://cdn.discordapp.com/attachments/752578049064697906/753228626752831609/zefQXQ7XrXo.jpg", "https://cdn.discordapp.com/attachments/752578049064697906/753243489512194098/DCIM_2019-02-23-5285246.png", "https://cdn.discordapp.com/attachments/752578049064697906/753616272217866341/catjammercar_sqenu_is_rarted_v2.gif", "https://cdn.discordapp.com/attachments/752578049064697906/755897138956861572/unknown.png", "https://cdn.discordapp.com/attachments/752578049064697906/758121802643013643/2019112610435374.png", "https://cdn.discordapp.com/attachments/752578049064697906/758122531721969694/20190129_033224252.png", "https://cdn.discordapp.com/attachments/752578049064697906/758123152521166848/unknown.png", "https://cdn.discordapp.com/attachments/655083079324532759/760163314734071879/72327593_1673268889469772_6064536625596071936_n.png", "https://cdn.discordapp.com/attachments/752578049064697906/761441490282217483/Screenshot_2020-09-06-21-51-27.png", "https://cdn.discordapp.com/attachments/752578049064697906/761526785392246794/Screenshot_2020-09-06-22-00-19-1.png", "https://cdn.discordapp.com/attachments/701698502060671079/761639368376844308/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639646392090644/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639772799762472/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639797151236106/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761640053695971348/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639828935934003/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639815031947344/image.jpg" }; for (int x = 0; x < jsonn.ModList.Length; x++) { Mod mod = new Mod() { Author = jsonn.ModList[x].Author, Link = jsonn.ModList[x].Link, Name = jsonn.ModList[x].Name, Date = jsonn.ModList[x].Date, Description = jsonn.ModList[x].Description, Version = jsonn.ModList[x].Version }; mod.StarScore = web2.DownloadString("http://tldworkshop.hopto.org/getrating.php?name=" + mod.Name); mod.StarScore = Regex.Replace(mod.StarScore, @"[ \r\n\t]", ""); mod.StarScore += "/5"; mod.DownloadsCount = "Downloads: "; mod.DownloadsCount += web2.DownloadString("http://tldworkshop.hopto.org/getrating.php?downloads=true&name=" + mod.Name); mod.DownloadsCount = Regex.Replace(mod.DownloadsCount, @"[\r\n\t]", ""); if (jsonn.ModList[x].PictureLink.Contains(".png")) { mod.PictureLink = jsonn.ModList[x].PictureLink; } else { mod.PictureLink = "http://tldworkshop.hopto.org/mods/pictures/notfound.png"; } ModListings.Add(new ModListing(mod)); } downloadbar.Visible = false; downloadperc.Visible = false; downloadtext.Visible = false; selectedMod = null; } if (mods == 1) { DataContractJsonSerializer json1 = new DataContractJsonSerializer(typeof(JSONN)); WebClient web = new WebClient(); WebClient web2 = new WebClient(); JSONN jsonn = (JSONN)json1.ReadObject(new System.IO.MemoryStream(web.DownloadData("http://tldworkshop.hopto.org/modlist_2.json"))); string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"TheLongDrive\Mods"); ModListings.Clear(); ItemList.Controls.Clear(); download.Text = "Delete"; mymods.Text = "Back"; mymods.Visible = false; string[] h = new string[] { "https://cdn.discordapp.com/attachments/752578049064697906/753228626752831609/zefQXQ7XrXo.jpg", "https://cdn.discordapp.com/attachments/752578049064697906/753243489512194098/DCIM_2019-02-23-5285246.png", "https://cdn.discordapp.com/attachments/752578049064697906/753616272217866341/catjammercar_sqenu_is_rarted_v2.gif", "https://cdn.discordapp.com/attachments/752578049064697906/755897138956861572/unknown.png", "https://cdn.discordapp.com/attachments/752578049064697906/758121802643013643/2019112610435374.png", "https://cdn.discordapp.com/attachments/752578049064697906/758122531721969694/20190129_033224252.png", "https://cdn.discordapp.com/attachments/752578049064697906/758123152521166848/unknown.png", "https://cdn.discordapp.com/attachments/655083079324532759/760163314734071879/72327593_1673268889469772_6064536625596071936_n.png", "https://cdn.discordapp.com/attachments/752578049064697906/761441490282217483/Screenshot_2020-09-06-21-51-27.png", "https://cdn.discordapp.com/attachments/752578049064697906/761526785392246794/Screenshot_2020-09-06-22-00-19-1.png", "https://cdn.discordapp.com/attachments/701698502060671079/761639368376844308/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639646392090644/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639772799762472/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639797151236106/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761640053695971348/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639828935934003/image.jpg", "https://cdn.discordapp.com/attachments/701698502060671079/761639815031947344/image.jpg" }; for (int x = 0; x < jsonn.ModList.Length; x++) { if (System.IO.File.Exists(path + "/" + jsonn.ModList[x].Name + ".dll")) { Mod mod = new Mod() { Author = jsonn.ModList[x].Author, Link = jsonn.ModList[x].Link, Name = jsonn.ModList[x].Name, Date = jsonn.ModList[x].Date, Description = jsonn.ModList[x].Description, Version = jsonn.ModList[x].Version }; mod.StarScore = web2.DownloadString("http://tldworkshop.hopto.org/getrating.php?name=" + mod.Name); mod.StarScore = Regex.Replace(mod.StarScore, @"[ \r\n\t]", ""); mod.StarScore += "/5"; mod.DownloadsCount = "Downloads: "; mod.DownloadsCount += web2.DownloadString("http://tldworkshop.hopto.org/getrating.php?downloads=true&name=" + mod.Name); mod.DownloadsCount = Regex.Replace(mod.DownloadsCount, @"[\r\n\t]", ""); if (jsonn.ModList[x].PictureLink.Contains(".png")) { mod.PictureLink = jsonn.ModList[x].PictureLink; } else { mod.PictureLink = "http://tldworkshop.hopto.org/mods/pictures/notfound.png"; } ModListings.Add(new ModListing(mod)); } } downloadbar.Visible = false; downloadperc.Visible = false; downloadtext.Visible = false; selectedMod = null; } }
/// <inheritdoc /> public bool TryFromString(ReadOnlySpan <char> str, [MaybeNullWhen(false)] out ModListing listing) { return(ModListing.TryFromString(str, _hasEnabledMarkers.HasEnabledMarkers, out listing)); }
/// <inheritdoc /> public bool TryFromFileName(FileName fileName, [MaybeNullWhen(false)] out ModListing listing) { return(ModListing.TryFromFileName(fileName, _hasEnabledMarkers.HasEnabledMarkers, out listing)); }
/// <inheritdoc /> public ModListing FromString(ReadOnlySpan <char> str) { return(ModListing.FromString(str, _hasEnabledMarkers.HasEnabledMarkers)); }
/// <inheritdoc /> public ModListing FromFileName(FileName name) { return(ModListing.FromFileName(name, _hasEnabledMarkers.HasEnabledMarkers)); }
public Mod(ModConfiguration modInstallation, ModListing modListing) { Installation = modInstallation; Listing = modListing; }