Ejemplo n.º 1
0
        public void TestInstallFrameworkUpdate()
        {
            MockArchiveFile archive = new MockArchiveFile(null, "C:\\temp.zip");

            new MockArchiveFile(archive, "GamesManager.exe.config", "GamesManagerConfig");
            new MockArchiveFile(archive, "GamesManager.exe", "GamesManager");
            new MockArchiveFile(archive, "GamesManager.Common.dll", "GamesManagerCommon");
            var schemas = new MockArchiveFile(archive, "schemas");

            new MockArchiveFile(schemas, "game.xsd", "GameSchema");
            ((MockArchiveFactory)ArchiveFactory.Current).VirtualArchives.Add("C:\\temp.zip", archive);


            MockFile gamesManagerFile = (MockFile)FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.exe");

            gamesManagerFile.WriteText("EXECUTABLE");
            gamesManagerFile.AssemblyVersion = new Version(1, 0, 0, 0);

            FrameworkUpdater updater = new FrameworkUpdater("C:\\temp.zip");

            updater.Start();

            Assert.IsTrue(FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.New.exe").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.exe.config").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.Common.dll").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("C:\\program files\\MGDF\\schemas\\game.xsd").Exists);

            Assert.AreEqual(new Version(1, 0, 0, 0), FileSystem.Current.GetFile("C:\\program files\\MGDF\\GamesManager.exe").AssemblyVersion);
        }
Ejemplo n.º 2
0
        public void TestLoadInvalidGame()
        {
            MockArchiveFile archive = new MockArchiveFile(null, "C:\\Documents and Settings\\user\\desktop\\game.zip");

            new MockArchiveFile(archive, "game.json", ReadTextFile("console.json"));
            new MockArchiveFile(archive, "preferences.json", ReadTextFile("preferences.json"));
            new MockArchiveFile(archive, "bin");
            //missing content
            ((MockArchiveFactory)ArchiveFactory.Current).VirtualArchives.Add("C:\\Documents and Settings\\user\\desktop\\game.zip", archive);

            GameInstall install = new GameInstall("C:\\Documents and Settings\\user\\desktop\\game.zip");

            Assert.IsFalse(install.IsValid);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public void TestInstallLocalUpdateToInstalledGame()
        {
            //lets pretend that this game is already installed.
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").WriteText(ReadTextFile("console.json"));
            FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game\\content").Create();
            FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\content\\test.json").WriteText("blah");
            Registry.Current.CreateSubKey(BaseRegistryKey.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MGDF1_Console");

            MockArchiveFile archive = new MockArchiveFile(null, "C:\\Documents and Settings\\user\\desktop\\game.zip");

            new MockArchiveFile(archive, "game.json", @"{
  ""gameUid"":""Console"",
  ""gameName"":""Lua Console"",
  ""description"":""A Lua command console for interacting with the MGDF system"",
  ""version"":""1.0.0.0"",
  ""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"":""*****@*****.**""
}");
            new MockArchiveFile(archive, "update.json", ReadTextFile("update.json"));
            new MockArchiveFile(archive, "content");
            new MockArchiveFile(archive, "bin");
            ((MockArchiveFactory)ArchiveFactory.Current).VirtualArchives.Add("C:\\Documents and Settings\\user\\desktop\\game.zip", archive);

            GameInstall install = new GameInstall("C:\\Documents and Settings\\user\\desktop\\game.zip");

            Assert.IsTrue(install.IsValid);

            GameUpdater updater = new GameUpdater(install);

            updater.Start();

            //check that all the games content was copied across
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").Exists);
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game\\content").Exists);
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game\\bin").Exists);
            //did the update remove the file specified
            Assert.IsFalse(FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\content\\test.json").Exists);

            Game game = new Game("c:\\program files\\MGDF\\game\\game.json");

            Assert.IsTrue(game.IsValid);

            GameRegistrar registrar = new GameRegistrar(true, game);

            registrar.Start();

            //assert the shortcuts are in the right place
            var key = Registry.Current.OpenSubKey(BaseRegistryKey.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MGDF1_Console");

            Assert.IsNotNull(key);
            Assert.AreEqual("c:\\program files\\MGDF\\resources\\gamesystemicon.ico", key.GetValue("DisplayIcon"));
            Assert.AreEqual("Lua Console", key.GetValue("DisplayName"));
            Assert.AreEqual("http://www.junkship.org", key.GetValue("URLInfoAbout"));
            Assert.AreEqual(1, key.GetDwordValue("NoModify"));
            Assert.AreEqual(1, key.GetDwordValue("NoRepair"));
            Assert.AreEqual("no8 interactive", key.GetValue("Publisher"));
            Assert.AreEqual("c:\\program files\\MGDF\\game", key.GetValue("InstallLocation"));
            Assert.AreEqual("1.0.0.0", key.GetValue("DisplayVersion"));

            //assert the shortcuts are in the right place
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\desktop\\Lua Console.lnk").Exists);
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\Documents and Settings\\user\\start menu\\no8 interactive").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\start menu\\no8 interactive\\Lua Console.lnk").Exists);

            registrar = new GameRegistrar(false, game);
            registrar.Start();

            //assert the registry key has been removed
            key = Registry.Current.OpenSubKey(BaseRegistryKey.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MGDF1_Console");
            Assert.IsNull(key);

            //shortcuts should have been removed
            Assert.IsFalse(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\desktop\\Lua Console.lnk").Exists);
            Assert.IsFalse(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\start menu\\no8 interactive\\Lua Console.lnk").Exists);
        }
Ejemplo n.º 5
0
        public void TestUpdateLocalGameWithFullInstaller(bool includeGdfDll)
        {
            MockArchiveFile archive = new MockArchiveFile(null, "C:\\Documents and Settings\\user\\desktop\\game.zip");

            new MockArchiveFile(archive, "game.json", ReadTextFile("console.json"));
            new MockArchiveFile(archive, "preferences.json", ReadTextFile("preferences.json"));
            if (includeGdfDll)
            {
                new MockArchiveFile(archive, "gdf.dll", "GAMES_EXPLORER_DEFINITION");
            }
            new MockArchiveFile(archive, "content");
            new MockArchiveFile(archive, "bin");
            ((MockArchiveFactory)ArchiveFactory.Current).VirtualArchives.Add("C:\\Documents and Settings\\user\\desktop\\game.zip", archive);

            var gameInstall = new GameInstall("C:\\Documents and Settings\\user\\desktop\\game.zip");

            Assert.IsTrue(gameInstall.IsValid);

            GameUpdater updater = new GameUpdater(gameInstall);

            updater.Start();

            //check that all the games content was copied across
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\game.json").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\program files\\MGDF\\game\\preferences.json").Exists);
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game\\content").Exists);
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\program files\\MGDF\\game\\bin").Exists);

            Game game = new Game("c:\\program files\\MGDF\\game\\game.json");

            Assert.IsTrue(game.IsValid);

            var key = Registry.Current.CreateSubKey(BaseRegistryKey.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MGDF1_Console");

            GameRegistrar registrar = new GameRegistrar(true, game);

            registrar.Start();

            //assert the shortcuts are in the right place
            key = Registry.Current.OpenSubKey(BaseRegistryKey.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MGDF1_Console");
            Assert.IsNotNull(key);
            Assert.AreEqual("c:\\program files\\MGDF\\resources\\gamesystemicon.ico", key.GetValue("DisplayIcon"));
            Assert.AreEqual("Lua Console", key.GetValue("DisplayName"));
            Assert.AreEqual("http://www.junkship.org", key.GetValue("URLInfoAbout"));
            Assert.AreEqual(1, key.GetDwordValue("NoModify"));
            Assert.AreEqual(1, key.GetDwordValue("NoRepair"));
            Assert.AreEqual("no8 interactive", key.GetValue("Publisher"));
            Assert.AreEqual("c:\\program files\\MGDF\\game", key.GetValue("InstallLocation"));
            Assert.AreEqual("0.1", key.GetValue("DisplayVersion"));

            //assert the shortcuts are in the right place
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\desktop\\Lua Console.lnk").Exists);
            Assert.IsTrue(FileSystem.Current.GetDirectory("c:\\Documents and Settings\\user\\start menu\\no8 interactive").Exists);
            Assert.IsTrue(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\start menu\\no8 interactive\\Lua Console.lnk").Exists);

            //assert the the game has been added to the games explorer
            Assert.AreEqual(includeGdfDll, GameExplorer.Current.IsInstalled("c:\\program files\\MGDF\\game\\gdf.dll"));

            //deregister the game
            registrar = new GameRegistrar(false, game);
            registrar.Start();

            //assert the shortcut has been removed
            key = Registry.Current.OpenSubKey(BaseRegistryKey.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\MGDF1_Console");
            Assert.IsNull(key);

            //shortcuts should have been removed
            Assert.IsFalse(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\desktop\\Lua Console.lnk").Exists);
            Assert.IsFalse(FileSystem.Current.GetFile("c:\\Documents and Settings\\user\\start menu\\no8 interactive\\Lua Console.lnk").Exists);

            if (includeGdfDll)
            {
                //assert the the game has been removed from the games explorer
                Assert.IsTrue(!GameExplorer.Current.IsInstalled("c:\\program files\\MGDF\\game\\gdf.dll"));
            }
        }