public void AddPlatform_Test() { string filename = Path.GetTempFileName(); var fakePluginManager = new Mock<IPluginManager>(); var fakeEmulatorBridge = new Mock<IEmulatorBridge>(); var fakeScraper = new Mock<IScraper>(); var fakePlatform = new Mock<IPlatformInfo>(); IList<string> supportedPlatforms = new List<string> { "TESTPLATFORM" }; fakeEmulatorBridge.SetupGet(bridge => bridge.PluginName).Returns("FakeEmulator"); fakeEmulatorBridge.SetupGet(bridge => bridge.SupportedPlatforms).Returns(supportedPlatforms); fakeScraper.SetupGet(scraper => scraper.PluginName).Returns("FakeScraper"); fakeScraper.SetupGet(scraper => scraper.SupportedPlatforms).Returns(supportedPlatforms); IDictionary<string, IEmulatorBridge> loadedEmulators = new Dictionary<string, IEmulatorBridge> { {"FakeEmulator", fakeEmulatorBridge.Object} }; IDictionary<string, IScraper> loadedScrapers = new Dictionary<string, IScraper> { {"FakeScraper", fakeScraper.Object} }; fakePluginManager.SetupGet(manager => manager.Plugins<IEmulatorBridge>()).Returns(loadedEmulators); fakePluginManager.SetupGet(manager => manager.Plugins<IScraper>()).Returns(loadedScrapers); fakePlatform.SetupGet(platform => platform.PlatformID).Returns("TESTPLATFORM"); IPlatformPreferenceDatabase database = new PlatformPreferencesDatabase(filename, fakePluginManager.Object); database.AddPlatform(fakePlatform.Object); var expectedPrefs = new PlatformDefaults("FakeScraper", "FakeEmulator"); Assert.Equal(expectedPrefs.Emulator, database.GetPreferences(fakePlatform.Object).Emulator); Assert.Equal(expectedPrefs.Scraper, database.GetPreferences(fakePlatform.Object).Scraper); this.DisposeSqlite(); File.Delete(filename); }
public void CreateDatabase_Test() { string filename = Path.GetTempFileName(); var fakePluginManager = new Mock<IPluginManager>(); var fakeEmulatorBridge = new Mock<IEmulatorBridge>(); var fakeScraper = new Mock<IScraper>(); IList<string> supportedPlatforms = new List<string> { "TESTPLATFORM" }; fakeEmulatorBridge.SetupGet(bridge => bridge.PluginName).Returns("FakeEmulator"); fakeEmulatorBridge.SetupGet(bridge => bridge.SupportedPlatforms).Returns(supportedPlatforms); fakeScraper.SetupGet(scraper => scraper.PluginName).Returns("FakeScraper"); fakeScraper.SetupGet(scraper => scraper.SupportedPlatforms).Returns(supportedPlatforms); IDictionary<string, IEmulatorBridge> loadedEmulators = new Dictionary<string, IEmulatorBridge> { {"FakeEmulator", fakeEmulatorBridge.Object} }; IDictionary<string, IScraper> loadedScrapers = new Dictionary<string, IScraper> { {"FakeScraper", fakeScraper.Object} }; fakePluginManager.SetupGet(manager => manager.Plugins<IEmulatorBridge>()).Returns(loadedEmulators); fakePluginManager.SetupGet(manager => manager.Plugins<IScraper>()).Returns(loadedScrapers); IPlatformPreferenceDatabase database = new PlatformPreferencesDatabase(filename, fakePluginManager.Object); Assert.NotNull(database); this.DisposeSqlite(); File.Delete(filename); }