public void SearchForEmulatorsTest()
        {
            var defs      = EmulatorDefinition.GetDefinitions();
            var emulators = EmulatorFinder.SearchForEmulators(@"d:\Emulators\", defs);

            CollectionAssert.IsNotEmpty(emulators);
        }
Пример #2
0
        public LiteDatabase OpenDatabase()
        {
            if (string.IsNullOrEmpty(Path))
            {
                throw new Exception("Database path cannot be empty.");
            }

            var dbExists = File.Exists(Path);

            logger.Info("Opening db " + Path);
            CloseDatabase();
            Database = new LiteDatabase($"Filename={Path};Mode=Exclusive");

            // To force litedb to try to open file, should throw exceptuion if something is wrong with db file
            Database.GetCollectionNames();

            if (!dbExists)
            {
                Database.Engine.UserVersion = DBVersion;
            }
            else
            {
                if (Database.Engine.UserVersion > DBVersion)
                {
                    throw new Exception($"Database version {Database.Engine.UserVersion} is not supported.");
                }

                if (GetMigrationRequired(Database))
                {
                    throw new Exception("Database must be migrated before opening.");
                }
            }

            GamesCollection     = Database.GetCollection <IGame>("games");
            PlatformsCollection = Database.GetCollection <Platform>("platforms");
            EmulatorsCollection = Database.GetCollection <Emulator>("emulators");

            if (!dbExists)
            {
                GamesCollection.EnsureIndex(a => a.Id);
                PlatformsCollection.EnsureIndex(a => a.Id);
                EmulatorsCollection.EnsureIndex(a => a.Id);

                // Generate default platforms
                if (File.Exists(EmulatorDefinition.DefinitionsPath))
                {
                    var platforms = EmulatorDefinition.GetDefinitions()
                                    .SelectMany(a => a.Profiles.SelectMany(b => b.Platforms)).Distinct()
                                    .Select(a => new Platform(a)).ToList();
                    AddPlatform(platforms);
                }
            }

            DatabaseOpened?.Invoke(this, null);
            IsOpen = true;
            return(Database);
        }
        public void SearchForGames()
        {
            var def      = EmulatorDefinition.GetDefinitions().First(a => a.Name == "PCSX2");
            var emulator = new Emulator("Test")
            {
                ImageExtensions = def.ImageExtensions
            };

            var games = EmulatorFinder.SearchForGames(@"d:\Emulators\_Games\PS2\", emulator);

            CollectionAssert.IsNotEmpty(games);
        }
Пример #4
0
        public async Task SearchForGamesTest()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\EmulatedGames\PS2\Devil May Cry 3.iso", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\Silen Hill 2.iso", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\Summoner 2.iso", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\WRC II Extreme.iso", MockFileData.NullObject }
            });

            var dirInfo = new MockDirectoryInfo(fileSystem, @"c:\EmulatedGames\");
            var def     = EmulatorDefinition.GetDefinitions().First(a => a.Name == "PCSX2");
            var games   = await EmulatorFinder.SearchForGames(dirInfo, def.Profiles.First().ToEmulatorConfig());

            Assert.AreEqual(4, games.Count);
        }
Пример #5
0
        public async Task SearchForEmulatorsTest()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\Emulators\WiiU\cemu_1.10.0\Cemu.exe", MockFileData.NullObject },
                { @"c:\Emulators\Genesis\Fusion364\Fusion.exe", MockFileData.NullObject },
                { @"c:\Emulators\PSP\PPSSPP\PPSSPPWindows.exe", MockFileData.NullObject },
                { @"c:\Emulators\GameCube_Wii\Dolphin\Dolphin.exe", MockFileData.NullObject }
            });

            var dirInfo   = new MockDirectoryInfo(fileSystem, @"c:\Emulators\");
            var defs      = EmulatorDefinition.GetDefinitions();
            var emulators = await EmulatorFinder.SearchForEmulators(dirInfo, defs);

            Assert.AreEqual(4, emulators.Count);
        }
Пример #6
0
        public async Task SearchForGamesTest()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\EmulatedGames\PS2\Devil May Cry 3.iso", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\Silen Hill 2.iso", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\Summoner 2.iso", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\WRC II Extreme.ISO", MockFileData.NullObject },
                { @"c:\EmulatedGames\PS2\Xenosaga Episode III - Also sprach Zarathustra (USA) (Disc 1).ISO.gz", MockFileData.NullObject }
            });

            var dirInfo = new MockDirectoryInfo(fileSystem, @"c:\EmulatedGames\");
            var def     = EmulatorDefinition.GetDefinitions().First(a => a.Name == "PCSX2");
            var games   = await EmulatorFinder.SearchForGames(dirInfo, def.Profiles.First().ToEmulatorConfig());

            Assert.AreEqual(5, games.Count);
            Assert.IsTrue(games[3].Name.EndsWith("Extreme"));
            Assert.IsTrue(games[4].Name.EndsWith("Zarathustra"));
        }
Пример #7
0
        public void GetDefinitionsTest()
        {
            var defs = EmulatorDefinition.GetDefinitions();

            CollectionAssert.IsNotEmpty(defs);
        }