예제 #1
0
        public async Task GameLibraryIntegrationCreateAsync_Test()
        {
            var path = new DirectoryInfo(Path.GetTempPath())
                       .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
            var fs  = new PhysicalFileSystem();
            var gfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(path.FullName));

            var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();

            optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
            var glib = new GameRecordLibrary(optionsBuilder);
            var gl   = new GameLibrary(glib);
            var game = await gl.CreateGameAsync("NINTENDO_NES");
        }
예제 #2
0
        public async Task GameLibraryIntegrationQueryAsync_Test()
        {
            var path = new DirectoryInfo(Path.GetTempPath())
                       .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
            var fs  = new PhysicalFileSystem();
            var gfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(path.FullName));

            var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();

            optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
            var glib = new GameRecordLibrary(optionsBuilder);
            var gl   = new GameLibrary(glib);
            var game = await gl.CreateGameAsync("NINTENDO_NES");

            Assert.False(await gl.QueryGamesAsync(g => g.PlatformID == "NINTENDO_NES").IsEmptyAsync());
            Assert.False(await gl.GetAllGamesAsync().IsEmptyAsync());
            Assert.NotNull(await gl.GetGameAsync(game.Record.RecordID));
        }
예제 #3
0
        public async Task GameLibraryIntegrationConfigAsync_Test()
        {
            var path = new DirectoryInfo(Path.GetTempPath())
                       .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
            var fs  = new PhysicalFileSystem();
            var gfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(path.FullName));

            var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();

            optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
            var glib = new GameRecordLibrary(optionsBuilder);
            var ccs  = new ConfigurationCollectionStore(optionsBuilder);

            var gl = new GameLibrary(glib);

            gl.AddExtension <IGameConfigurationExtensionProvider, IGameConfigurationExtension>
                (new GameConfigurationExtensionProvider(ccs));
            var game = await gl.CreateGameAsync("NINTENDO_NES");

            var profile = await game.WithConfigurations()
                          .CreateNewProfileAsync <ExampleConfigurationCollection>("TestConfiguration", "test");

            var profileGuid = profile.CollectionGuid;

            Assert.NotNull(await game.WithConfigurations()
                           .GetProfileAsync <ExampleConfigurationCollection>("TestConfiguration", profileGuid));

            Assert.NotEmpty(game.WithConfigurations().GetProfileNames());

            profile.Configuration.ExampleConfiguration.FullscreenResolution =
                Configuration.FullscreenResolution.Resolution1600X1050;
            await gl.WithConfigurationLibrary().UpdateProfileAsync(profile);

            var newProfile = await game.WithConfigurations()
                             .GetProfileAsync <ExampleConfigurationCollection>("TestConfiguration", profileGuid);

            Assert.Equal(Configuration.FullscreenResolution.Resolution1600X1050,
                         newProfile.Configuration.ExampleConfiguration.FullscreenResolution);

            await game.WithConfigurations().DeleteProfileAsync("TestConfiguration", profileGuid);

            Assert.Empty(game.WithConfigurations().GetProfileNames());
        }
예제 #4
0
        public async Task GameLibraryUnknownExtensionAsync_Test()
        {
            var path = new DirectoryInfo(Path.GetTempPath())
                       .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
            var fs  = new PhysicalFileSystem();
            var gfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(path.FullName));

            var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();

            optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
            var glib = new GameRecordLibrary(optionsBuilder);
            var ccs  = new ConfigurationCollectionStore(optionsBuilder);

            var gl = new GameLibrary(glib);

            Assert.Throws <KeyNotFoundException>(() => gl.GetExtension <IGameConfigurationExtensionProvider>());
            var game = await gl.CreateGameAsync("NINTENDO_NES");

            Assert.Throws <KeyNotFoundException>(() => game.GetExtension <IGameConfigurationExtension>());
        }
예제 #5
0
        public async Task GameLibraryIntegrationUpdateAsync_Test()
        {
            var path = new DirectoryInfo(Path.GetTempPath())
                       .CreateSubdirectory(Path.GetFileNameWithoutExtension(Path.GetTempFileName()));
            var fs  = new PhysicalFileSystem();
            var gfs = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(path.FullName));

            var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();

            optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
            var glib = new GameRecordLibrary(optionsBuilder);
            var flib = new FileRecordLibrary(optionsBuilder);

            var gl = new GameLibrary(glib);

            gl.AddExtension <GameFileExtensionProvider, IGameFileExtension
                             >(new GameFileExtensionProvider(flib, gfs));

            var game = await gl.CreateGameAsync("NINTENDO_NES");

            game.Record.Title = "My Awesome Game";
            await gl.UpdateGameRecordAsync(game.Record);

            var file = game.WithFiles().MiscRoot.OpenFile("Test.txt");

            file.OpenStream().Close();
            await game.WithFiles().RegisterFileAsync(file, "application/text");

            var record = await game.WithFiles().GetFileInfoAsync(file);

            record.Metadata.Add("file_metadata", "test");
            await gl.GetExtension <GameFileExtensionProvider>().UpdateFileAsync(record);

            var newGame = await gl.GetGameAsync(game.Record.RecordID);

            Assert.False(await newGame.WithFiles().GetFileRecordsAsync().IsEmptyAsync());
        }