Пример #1
0
        public void Registrar_TestEverything()
        {
            RegistrarClient registrar = new RegistrarClient("LocalHttpBinding_IRegistrar");

            // RegistrarClient registrar = new RegistrarClient("ProdHttpBinding_IRegistrar");

            Common.EndPoint ep0 = new Common.EndPoint("129.143.23.10:2300");
            GameInfo        g0  = registrar.RegisterGame("Test Game 0", ep0);

            Assert.IsNotNull(g0);
            Assert.AreEqual("Test Game 0", g0.Label);
            Assert.AreEqual(ep0.Address, g0.CommunicationEndPoint.Address);
            Assert.AreEqual(ep0.Port, g0.CommunicationEndPoint.Port);
            Assert.AreEqual(GameInfo.GameStatus.NOT_INITIAlIZED, g0.Status);

            Common.EndPoint ep1 = new Common.EndPoint("129.143.23.10:2304");
            GameInfo        g1  = registrar.RegisterGame("Test Game 1", ep1);

            Assert.IsNotNull(g1);
            Assert.AreEqual("Test Game 1", g1.Label);
            Assert.AreEqual(ep1.Address, g1.CommunicationEndPoint.Address);
            Assert.AreEqual(ep1.Port, g1.CommunicationEndPoint.Port);
            Assert.AreEqual(GameInfo.GameStatus.NOT_INITIAlIZED, g0.Status);

            GameInfo[] games = registrar.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsTrue(GamesContain(games, g0.Id, g0.Label));
            Assert.IsTrue(GamesContain(games, g1.Id, g1.Label));

            GameInfoAlt[] gamesAlt = registrar.GetGamesAlt(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsTrue(GamesContainAlt(gamesAlt, g0.Id, g0.Label));
            Assert.IsTrue(GamesContainAlt(gamesAlt, g1.Id, g1.Label));

            registrar.ChangeStatus(g1.Id, GameInfo.GameStatus.AVAILABLE);
            games = registrar.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsTrue(GamesContain(games, g0.Id, g0.Label));
            games = registrar.GetGames(GameInfo.GameStatus.AVAILABLE);
            Assert.IsTrue(GamesContain(games, g1.Id, g1.Label));

            for (int i = 0; i < 90; i++)
            {
                Thread.Sleep(1000);
                registrar.AmAlive(g1.Id);
            }

            games = registrar.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsFalse(GamesContain(games, g0.Id, g0.Label));
            games = registrar.GetGames(GameInfo.GameStatus.AVAILABLE);
            Assert.IsTrue(GamesContain(games, g1.Id, g1.Label));
        }
        public void Registrar_TestEverything()
        {
            RegistrarClient registrar = new RegistrarClient("LocalHttpBinding_IRegistrar");
            // RegistrarClient registrar = new RegistrarClient("ProdHttpBinding_IRegistrar");

            Common.EndPoint ep0 = new Common.EndPoint("129.143.23.10:2300");
            GameInfo g0 = registrar.RegisterGame("Test Game 0", ep0);
            Assert.IsNotNull(g0);
            Assert.AreEqual("Test Game 0", g0.Label);
            Assert.AreEqual(ep0.Address, g0.CommunicationEndPoint.Address);
            Assert.AreEqual(ep0.Port, g0.CommunicationEndPoint.Port);
            Assert.AreEqual(GameInfo.GameStatus.NOT_INITIAlIZED, g0.Status);

            Common.EndPoint ep1 = new Common.EndPoint("129.143.23.10:2304");
            GameInfo g1 = registrar.RegisterGame("Test Game 1", ep1);
            Assert.IsNotNull(g1);
            Assert.AreEqual("Test Game 1", g1.Label);
            Assert.AreEqual(ep1.Address, g1.CommunicationEndPoint.Address);
            Assert.AreEqual(ep1.Port, g1.CommunicationEndPoint.Port);
            Assert.AreEqual(GameInfo.GameStatus.NOT_INITIAlIZED, g0.Status);

            GameInfo[] games = registrar.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsTrue(GamesContain(games, g0.Id, g0.Label));
            Assert.IsTrue(GamesContain(games, g1.Id, g1.Label));

            GameInfoAlt[] gamesAlt = registrar.GetGamesAlt(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsTrue(GamesContainAlt(gamesAlt, g0.Id, g0.Label));
            Assert.IsTrue(GamesContainAlt(gamesAlt, g1.Id, g1.Label));

            registrar.ChangeStatus(g1.Id, GameInfo.GameStatus.AVAILABLE);
            games = registrar.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsTrue(GamesContain(games, g0.Id, g0.Label));
            games = registrar.GetGames(GameInfo.GameStatus.AVAILABLE);
            Assert.IsTrue(GamesContain(games, g1.Id, g1.Label));

            for (int i = 0; i < 90; i++)
            {
                Thread.Sleep(1000);
                registrar.AmAlive(g1.Id);
            }

            games = registrar.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);
            Assert.IsFalse(GamesContain(games, g0.Id, g0.Label));
            games = registrar.GetGames(GameInfo.GameStatus.AVAILABLE);
            Assert.IsTrue(GamesContain(games, g1.Id, g1.Label));
        }
Пример #3
0
        static void Main(string[] args)
        {
            RegistrarClient registry = new RegistrarClient();

            EndPoint myEP = new EndPoint() {Address = 1352522, Port=2354 };
            GameInfo myGame = registry.RegisterGame("Test Game",  myEP);

            GameInfo[] games = registry.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);

            registry.ChangeStatus(myGame.Id, GameInfo.GameStatus.AVAILABLE);
            games = registry.GetGames(GameInfo.GameStatus.AVAILABLE);

            registry.AmAlive(myGame.Id);
            games = registry.GetGames(GameInfo.GameStatus.AVAILABLE);

            Thread.Sleep(90000);
            games = registry.GetGames(GameInfo.GameStatus.AVAILABLE);
        }
Пример #4
0
        static void Main(string[] args)
        {
            RegistrarClient registry = new RegistrarClient();

            EndPoint myEP = new EndPoint()
            {
                Address = 1352522, Port = 2354
            };
            GameInfo myGame = registry.RegisterGame("Test Game", myEP);

            GameInfo[] games = registry.GetGames(GameInfo.GameStatus.NOT_INITIAlIZED);

            registry.ChangeStatus(myGame.Id, GameInfo.GameStatus.AVAILABLE);
            games = registry.GetGames(GameInfo.GameStatus.AVAILABLE);

            registry.AmAlive(myGame.Id);
            games = registry.GetGames(GameInfo.GameStatus.AVAILABLE);

            Thread.Sleep(90000);
            games = registry.GetGames(GameInfo.GameStatus.AVAILABLE);
        }