public void TestServerDtor2()
        {
            Server serv = new Server(1234);

            serv.Dispose();
            serv.Run();
        }
        public void TestServerDtor3()
        {
            Server serv       = new Server();
            Thread servThread = new Thread(serv.Run);

            servThread.Start();
            serv.Dispose();
            Assert.IsFalse(servThread.IsAlive);
        }
        public void TestSetPortConnection()
        {
            Server serv = new Server(5000);

            StartServerThread(serv);
            Client client = new Client(5000);

            Assert.AreEqual(0, client.Process(new string[] { }));
            serv.Dispose();
        }
Beispiel #4
0
        private static void TestServer()
        {
            Server s = new Server(new TestService(), Client.DefaultHeartbeat);

            s.Bind("tcp://127.0.0.1:1234");
            Console.WriteLine("Server started");
            s.Error += (sender, errorArgs) => { Console.WriteLine($"Error: {errorArgs.Info}"); };
            Console.Read();
            Console.WriteLine("Closing");
            s.Dispose();
        }
Beispiel #5
0
        private static void Main(string[] args)
        {
            Server s = new Server(new SimpleWrapperService <TestObject>(new TestObject()));

            s.Bind("tcp://127.0.0.1:1234");
            Console.WriteLine("Server started");
            s.Error += (sender, errorArgs) => { Console.WriteLine($"Error: {errorArgs.Info}"); };
            Console.Read();
            Console.WriteLine("Closing");
            s.Dispose();
        }
Beispiel #6
0
        public void Dispose()
        {
            Disposes.Dispose();

            Clients.ForEach(x => {
                x.Close();
                x.Dispose();
            });

            Server?.Close();
            Server?.Dispose();
        }
        public void TestServerCtor()
        {
            Server serv = new Server();

            Assert.IsTrue(serv.Port > 0);
            serv.Dispose();

            serv = new Server(1234);
            Assert.AreEqual(1234, serv.Port);
            serv.Dispose();

            serv = new Server(5432);
            Assert.AreEqual(5432, serv.Port);
            serv.Dispose();
        }
        public void RegisterWithNoNewMaps()
        {
            var noFreePlanetGalaxy = new Galaxy
            {
                Factions = new List <Faction> {
                    new Faction("Core", Color.Red), new Faction("Arm", Color.Blue)
                },
                Players = new List <Player> {
                    new Player("Barack", "Arm"), new Player("John", "Core"),
                },
                MapNames = new List <string> {
                    "illinois", "arizona",
                },
                Planets =
                    new List <Planet>
                {
                    new Planet(0, 0.1f, 0.1f, "Barack", "Arm")
                    {
                        IsStartingPlanet = true, MapName = "illinois"
                    },
                    new Planet(1, 0.2f, 0.2f, "John", "Core")
                    {
                        IsStartingPlanet = true, MapName = "arizona"
                    },
                }
            };

            server.Dispose();
            using (var noFreePlanetServer = new Server(noFreePlanetGalaxy)
            {
                DontSave = true
            }) {
                var result = noFreePlanetServer.Register(springieAuth, new AuthInfo("test", "test"), "Core", null);
                Assert.AreEqual(
                    "Welcome to PlanetWars! You are in, but you don't own any planet (no free planets left.)", result);
                Assert.IsTrue(noFreePlanetServer.Galaxy.Players.Any(p => p.Name == "test"));
                Assert.IsTrue(
                    noFreePlanetServer.Galaxy.Events.Any(p => p.IsPlayerRelated("test") && p.IsFactionRelated("Core")));
            }
        }
 public void CleanUp()
 {
     serv.Dispose();
 }