public void LoadInvalidGameInvalidVersion() { const string InvalidVersion = @"{ ""gameUid"":""Console"", ""gameName"":""Lua Console"", ""description"":""A Lua command console for interacting with the MGDF system"", ""version"":""1.0 Beta 2"", ""interfaceVersion"":""1"", ""developerUid"":""no-8"", ""developerName"":""no8 interactive"", ""homepage"":""http://www.junkship.org"", ""gameSourceService"":""http://games.junkship.org/gamesource.asmx"", ""statisticsService"":""http://statistics.junkship.org/statisticsService.asmx"", ""statisticsPrivacyPolicy"":""We wont use ur informationz"", ""supportEmail"":""*****@*****.**"" }"; MockDirectory gameDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory + "\\game")); gameDirectory.AddFile("game.json", InvalidVersion); Game game = new Game(Path.Combine(EnvironmentSettings.Current.AppDirectory, "game\\game.json")); Assert.AreEqual(false, game.IsValid); Assert.AreEqual(1, game.ErrorCollection.Count); }
public void TestGetStatisticsPermissionNoCachedPermission(bool allow) { const string gmeContent = @"{ ""gameUid"":""Console"", ""gameName"":""Lua Console"", ""description"":""A Lua command console for interacting with the MGDF system"", ""version"":""0.1"", ""interfaceVersion"":""1"", ""developerUid"":""no-8"", ""developerName"":""no8 interactive"", ""homepage"":""http://www.junkship.org"", ""gamesourceService"":""http://games.junkship.org/gamesource.asmx"", ""statisticsService"":""http://statistics.junkship.org/statisticsservice.asmx"", ""statisticsPrivacyPolicy"":""http://www.junkship.org/privacy"", ""supportEmail"":""*****@*****.**"" }"; MockDirectory gameDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory + "\\game")); gameDirectory.AddFile("game.json", gmeContent); Game game = new Game(Path.Combine(EnvironmentSettings.Current.AppDirectory, "game\\game.json")); Resources.InitUserDirectory("Console", false); Assert.AreEqual(allow, StatisticsSession.GetStatisticsPermission(game, args => allow)); Assert.AreEqual(SettingsManager.Instance.Settings.GameUid, "Console"); Assert.AreEqual(allow, SettingsManager.Instance.Settings.StatisticsServiceEnabled.Value); }
public void TestGetStatisticsPermissionCachedPermission() { const string gameContent = @"{ ""gameuid"":""Console"", ""gamename"":""Lua Console"", ""description"":""A Lua command console for interacting with the MGDF system"", ""version"":""0.1"", ""interfaceversion"":""1"", ""developeruid"":""no-8"", ""developername"":""no8 interactive"", ""homepage"":""http://www.junkship.org"", ""gamesourceservice"":""http://games.junkship.org/gamesource.asmx"", ""statisticsservice"":""http://statistics.junkship.org/statisticsservice.asmx"", ""statisticsprivacypolicy"":""http://www.junkship.org/privacy"", ""supportemail"":""*****@*****.**"" }"; MockDirectory gameDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory + "\\game")); gameDirectory.AddFile("game.json", gameContent); Game game = new Game(Path.Combine(EnvironmentSettings.Current.AppDirectory, "game\\game.json")); Resources.InitUserDirectory("Console", false); SettingsManager.Instance.Settings = new GameSettings(); SettingsManager.Instance.Settings.GameUid = "Console"; SettingsManager.Instance.Settings.StatisticsServiceEnabled = true; SettingsManager.Instance.Save(); Assert.IsTrue(StatisticsSession.GetStatisticsPermission(game, args => { Assert.Fail("This get permission callback shouldn't be called when the permission has been cached"); return(false); })); }
public void TestLoadSaveStatisticsPermission() { Resources.InitUserDirectory("foo", false); MockDirectory userDirectory = ((MockDirectory)MockFileSystem.GetDirectory(Resources.GameUserDir)); var file = userDirectory.AddFile("GamesManagerSettings.json", @"{ ""game"": { ""uid"": ""foo"", ""userName"": ""bar"", ""passwordHash"": """ + DPAPI.Encrypt("baz") + @""", ""statisticsServiceEnabled"": true } }"); Assert.AreEqual(SettingsManager.Instance.Settings.GameUid, "foo"); Assert.AreEqual(SettingsManager.Instance.Settings.UserName, "bar"); Assert.AreEqual(SettingsManager.Instance.Settings.Password, "baz"); Assert.IsTrue(SettingsManager.Instance.Settings.StatisticsServiceEnabled.HasValue); Assert.IsTrue(SettingsManager.Instance.Settings.StatisticsServiceEnabled.Value); SettingsManager.Dispose(); file.WriteText(@"{ ""game"": { ""uid"": ""foo"", ""userName"": ""bar"", ""passwordHash"": """ + DPAPI.Encrypt("baz") + @""", } }"); Assert.IsFalse(SettingsManager.Instance.Settings.StatisticsServiceEnabled.HasValue); }
public void LoadGame() { MockDirectory gameDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory + "\\game")); gameDirectory.AddFile("game.json", ReadTextFile("console.json")); Game game = new Game(Path.Combine(EnvironmentSettings.Current.AppDirectory, "game\\game.json")); Assert.AreEqual("Console", game.Uid); Assert.AreEqual("Lua Console", game.Name); Assert.AreEqual(new Version(0, 1), game.Version); Assert.AreEqual("http://www.junkship.org", game.Homepage); Assert.AreEqual(1, game.InterfaceVersion); Assert.AreEqual("no8 interactive", game.DeveloperName); Assert.AreEqual(true, game.IsValid); Assert.AreEqual("http://games.junkship.org/gamesource.asmx", game.UpdateService); Assert.AreEqual("http://statistics.junkship.org/statisticsservice.asmx", game.StatisticsService); }
public void LoadDependenciesFile() { const string json = @"{ ""dependencies"":[ { ""command"": ""vc2013redist_x86.exe"", ""arguments"":""/q"" } ] }"; MockDirectory depsDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory)); depsDirectory = depsDirectory.AddDirectory("dependencies"); depsDirectory.AddFile("dependencies.json", json); var deps = new FrameworkDependencies(Resources.DependenciesFile); Assert.AreEqual(true, deps.IsValid); Assert.AreEqual(0, deps.ErrorCollection.Count); Assert.AreEqual(1, deps.Dependencies.Count); Assert.AreEqual("/q", deps.Dependencies["vc2013redist_x86.exe"]); }
public void TestCanSendStatisticsDeniedNoPrivacyPolicy() { const string gameContent = @"{ ""gameUid"":""Console"", ""gameName"":""Lua Console"", ""description"":""A Lua command console for interacting with the MGDF system"", ""version"":""0.1"", ""interfaceVersion"":""1"", ""developerUid"":""no-8"", ""developerName"":""no8 interactive"", ""homepage"":""http://www.junkship.org"", ""gamesourceService"":""http://games.junkship.org/gamesource.asmx"", ""statisticsService"":""http://statistics.junkship.org/statisticsservice.asmx"", ""supportEmail"":""*****@*****.**"" }"; MockDirectory gameDirectory = ((MockDirectory)MockFileSystem.GetDirectory(EnvironmentSettings.Current.AppDirectory + "\\game")); gameDirectory.AddFile("game.json", gameContent); Game game = new Game(Path.Combine(EnvironmentSettings.Current.AppDirectory, "game\\game.json")); Assert.IsFalse(StatisticsSession.CanSendStatistics(game)); }
public void LoadGameInstaller() { MockDirectory desktopDir = (MockDirectory)MockFileSystem.GetDirectory("C:\\Documents and Settings\\user\\desktop"); desktopDir.AddFile("game.zip", "data"); MockArchiveFile archive = new MockArchiveFile(null, "C:\\Documents and Settings\\user\\desktop\\game.mza"); new MockArchiveFile(archive, "game.json", ReadTextFile("console.json")); new MockArchiveFile(archive, "preferences.json", ReadTextFile("preferences.json")); new MockArchiveFile(archive, "content"); new MockArchiveFile(archive, "bin"); ((MockArchiveFactory)ArchiveFactory.Current).VirtualArchives.Add("C:\\Documents and Settings\\user\\desktop\\game.mza", archive); GameInstall install = new GameInstall("C:\\Documents and Settings\\user\\desktop\\game.mza"); Assert.IsNotNull(install); Assert.IsTrue(install.IsValid); Assert.AreEqual("http://games.junkship.org/gamesource.asmx", install.Game.UpdateService); Assert.AreEqual("http://www.junkship.org", install.Game.Homepage); Assert.AreEqual(1, install.Game.InterfaceVersion); Assert.IsFalse(install.IsUpdate); Assert.AreEqual("Lua Console", install.Game.Name); Assert.AreEqual("We wont use ur informationz", install.Game.StatisticsPrivacyPolicy); Assert.AreEqual("http://statistics.junkship.org/statisticsservice.asmx", install.Game.StatisticsService); Assert.AreEqual("*****@*****.**", install.Game.SupportEmail); Assert.AreEqual("Console", install.Game.Uid); Assert.AreEqual(new Version(0, 1), install.Game.Version); Assert.IsNull(install.Update); Assert.IsFalse(install.IsUpdate); Assert.AreEqual("C:\\Documents and Settings\\user\\desktop\\game.mza", install.InstallerFile); }