Exemple #1
0
            public void AddUser()
            {
                DiSetup.Tests();
                IUserService userService = DiHelper.GetService <IUserService>();

                userService.Clear();
                userService.CreateTestData();
                AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>();

                int usercountBefore = authenticationService.GetUsers().Count();

                var result = authenticationService.AddUser(new Models.User("Nigel Something"));

                int usercountAfter = authenticationService.GetUsers().Count();

                Assert.IsNotNull(result);
                Assert.AreEqual(true, result);
                Assert.IsTrue(usercountBefore + 1 == usercountAfter);
            }
Exemple #2
0
            public void AddUserNegative()
            {
                DiSetup.Tests();
                IUserService userService = DiHelper.GetService <IUserService>();

                userService.Clear();
                userService.CreateTestData();
                AuthenticationService authenticationService = DiHelper.GetService <AuthenticationService>();
                var existingUser = authenticationService.GetUser("123");

                int usercountBefore = authenticationService.GetUsers().Count();

                var result = authenticationService.AddUser(existingUser);  //try to add an existing user

                int usercountAfter = authenticationService.GetUsers().Count();

                Assert.IsNotNull(result);
                Assert.AreEqual(false, result);
                Assert.IsTrue(usercountBefore == usercountAfter);
            }
Exemple #3
0
        static void Main(string[] args)
        {
            // Setup some stuff, because why not
            Console.Title       = "Blasters Lobby Gateway";
            Console.WindowWidth = 100;

            // Write some welcoming info
            PrintLine(ConsoleColor.Yellow, "********************************************************************");
            PrintLine(ConsoleColor.Yellow, "This is beta software. You have been warned. Code by: Vaughan Hilts");
            PrintLine(ConsoleColor.Yellow, "********************************************************************\n");

            Logger.Instance.Log(Level.Info, "The lobby server has succesfully been started.");


            // Add services
            _serviceContainer.RegisterService(_authenticationService);
            _serviceContainer.RegisterService(_gameSessionService);
            _serviceContainer.RegisterService(_appServerService);
            _serviceContainer.RegisterService(_chatService);
            _serviceContainer.RegisterService(_intentService);


            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            ClientNetworkManager.Instance.Update();

            // We populate the game with some matches in debug mode


#if DEUBG
#endif

//            Thread.Sleep(5000);

            var context = new BlastersContext();

            // Retrieve that user from the db
            var member = context.blastersmembers.FirstOrDefault();



            // Create ten default games
            for (int i = 0; i < 1; i++)
            {
                _gameSessionService.CreateSession();
            }



            var done = false;



            while (true)
            {
                ClientNetworkManager.Instance.Update();

                _serviceContainer.PerformUpdates();



                Thread.Sleep(1);


#if DEBUG_MOCK
                if (done || _appServerService.ApplicationServers.Count == 0)
                {
                    continue;
                }

                // Dispatch a dummy match to the server in debug mode
                var _client = new NetClient(new NetPeerConfiguration("Inspire"));
                _client.Start();
                _client.Connect("localhost", 8787);
                Thread.Sleep(2000);
                var user = new BlastersShared.Models.User(_client.ServerConnection, "Vaughan");
                _authenticationService.AddUser(user);

                var demoSession = _gameSessionService.CreateSession();
                demoSession.Configuration.MaxPlayers = 1;


                _gameSessionService.AddToSession(user, demoSession);
                _gameSessionService.ActivateSession(demoSession);
                done = true;
#endif
            }



            Console.ReadLine();
        }