Пример #1
0
        public async Task AlreadyExistingSeed_Add()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await Task.Delay(50);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            Command command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            serverSettings = TestHelper.GenerateNewServerSetting();
            serverSettings.WorldGenSeed = getResponse.ServerSettings[0].WorldGenSeed;
            command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.GAME_SEED_ALREADY_EXISTS);
        }
Пример #2
0
        public async Task EditServerSettingsInDatabase()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await Task.Delay(50);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            Command command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            getResponse.ServerSettings[0].GameName = "Edited!";
            command = new Command("EditServerSettings", getResponse.ServerSettings[0]);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_EDITED);
        }
Пример #3
0
        private bool IsAttendanceUpdated()
        {
            var getSettingsRequest = GetSettingsRequest.CreateSettingRequest(ConstantFlags.LoginFlag, true.ToString());
            GetSettingsResponse getSettingsResponse = mediator.Send(getSettingsRequest).Result;

            return(getSettingsResponse == null ? false : getSettingsResponse.Success);
        }
Пример #4
0
        private static bool IsLoggedIn()
        {
            var                 getSettingsRequest  = GetSettingsRequest.CreateSettingRequest(ConstantHandlerMessages.IsLoggedIn, true.ToString());
            IMediator           mediator            = Mvx.IoCProvider.Resolve <IMediator>();
            GetSettingsResponse getSettingsResponse = mediator.Send(getSettingsRequest).Result;

            return(getSettingsResponse == null ? false : getSettingsResponse.Success);
        }
Пример #5
0
        public async Task <GetSettingsResponse> GetSettings(GetSettingsRequest o)
        {
            var result = new GetSettingsResponse(o.RequestId);

            result.Settings.AddRange((await Server.GetSettings(o.Application)));

            return(result);
        }
        public async Task StartAndShutdownServerWithGameMod()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();

            serverSettings.GameMod = "FastProgress";
            Command command = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            bool foundServerSetting = false;

            foreach (var item in getResponse.ServerSettings)
            {
                if (serverSettings.WorldGenSeed == item.WorldGenSeed)
                {
                    serverSettings     = item;
                    foundServerSetting = true;
                }
            }
            if (!foundServerSetting)
            {
                Assert.Fail("Added ServerSettingsId not found in response");
            }

            command = new Command("StartServer", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            StartServerResponse startResponse = JsonConvert.DeserializeObject <StartServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(startResponse, StartServerResult.SERVER_STARTED);

            command = new Command("StopServer", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            StopServerResponse stopResponse = JsonConvert.DeserializeObject <StopServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(stopResponse, StopServerResult.SERVER_STOPPED);
        }
Пример #7
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetSettingsResponse response = new GetSettingsResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("settings", targetDepth))
                {
                    var unmarshaller = SettingsUnmarshaller.Instance;
                    response.Settings = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Пример #8
0
        public override async Task <GetSettingsResponse> GetByBrokerId(GetSettingsByBrokerIdRequest request, ServerCallContext context)
        {
            var settings = await _settingsService.GetAsync(request.BrokerId);

            var result = new GetSettingsResponse();

            if (settings == null)
            {
                return(result);
            }

            var feesSettings = new FeesSettings();

            feesSettings.Id           = settings.Id;
            feesSettings.BrokerId     = settings.BrokerId;
            feesSettings.FeeAccountId = settings.FeeAccountId;
            feesSettings.FeeWalletId  = settings.FeeWalletId;
            feesSettings.Created      = settings.Created.ToTimestamp();
            feesSettings.Modified     = settings.Modified.ToTimestamp();

            result.Settings = feesSettings;

            return(result);
        }
        public async Task StartTwoServers()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettingOne = new ServerSetting
            {
                GameName              = "MyGameStartTwoServesOne",
                GameWorld             = Beste.GameServer.SDaysTDie.Modules.Types.GameWorld.Navezgane.ToString(),
                ServerConfigFilepath  = "MyGameConfigFilePath" + TestHelper.RandomString(8) + ".xml",
                ServerDescription     = "My Server Desc",
                ServerName            = "MyServerStartTwoServesOne",
                ServerPassword        = "******",
                ServerPort            = 50001,
                TelnetPassword        = "******",
                TelnetPort            = 8089,
                TerminalWindowEnabled = false,
                WorldGenSeed          = "MyGameStartTwoServesOne"
            };

            Command command = new Command("AddServerSetting", serverSettingOne);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            bool foundServerSetting = false;

            foreach (var item in getResponse.ServerSettings)
            {
                if (serverSettingOne.WorldGenSeed == item.WorldGenSeed)
                {
                    serverSettingOne   = item;
                    foundServerSetting = true;
                    break;
                }
            }
            if (!foundServerSetting)
            {
                Assert.Fail("Added ServerSettingsId not found in response");
            }



            command = new Command("StartServer", serverSettingOne);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            StartServerResponse startResponse = JsonConvert.DeserializeObject <StartServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(startResponse, StartServerResult.SERVER_STARTED);

            ClientWebSocket  webSocketTwo        = new ClientWebSocket();
            WebSocketHandler webSocketHandlerTwo = new WebSocketHandler(webSocketTwo);
            await webSocketTwo.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await TestHelper.Login("Admin", "Passwort1$", webSocketTwo, webSocketHandlerTwo);

            ServerSetting serverSettingTwo = new ServerSetting
            {
                GameName              = "MyGameStartTwoServesTwo",
                GameWorld             = Beste.GameServer.SDaysTDie.Modules.Types.GameWorld.Navezgane.ToString(),
                ServerConfigFilepath  = "MyGameConfigFilePath" + TestHelper.RandomString(8) + ".xml",
                ServerDescription     = "My Server Desc",
                ServerName            = "MyServerNameStartTwoServesTwo",
                ServerPassword        = "******",
                ServerPort            = 50001,
                TelnetPassword        = "******",
                TelnetPort            = 8089,
                TerminalWindowEnabled = false,
                WorldGenSeed          = "MyGameStartTwoServesTwo"
            };

            command = new Command("AddServerSetting", serverSettingTwo);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocketTwo, webSocketHandlerTwo, command);

            modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandlerTwo.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocketTwo, webSocketHandlerTwo, command);

            getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandlerTwo.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            foundServerSetting = false;
            foreach (var item in getResponse.ServerSettings)
            {
                if (serverSettingTwo.WorldGenSeed == item.WorldGenSeed)
                {
                    serverSettingTwo   = item;
                    foundServerSetting = true;
                    break;
                }
            }
            if (!foundServerSetting)
            {
                Assert.Fail("Added ServerSettingsId not found in response");
            }



            command = new Command("StartServer", serverSettingTwo);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocketTwo, webSocketHandlerTwo, command);

            startResponse = JsonConvert.DeserializeObject <StartServerResponse>(webSocketHandlerTwo.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(startResponse, StartServerResult.SERVER_STARTED);

            await Task.Delay(10000);

            int processCount = 0;

            foreach (var process in Process.GetProcessesByName("7DaysToDie"))
            {
                processCount++;
            }
            if (processCount != 2)
            {
                Assert.Fail("processCount != 2");
            }

            command = new Command("StopServer", serverSettingOne);
            await TestHelper.ExecuteCommandAndAwaitCommandResponse(webSocket, webSocketHandler, command, "StopServerResponse");

            StopServerResponse stopResponse = JsonConvert.DeserializeObject <StopServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(stopResponse, new StopServerResult[] { StopServerResult.SERVER_STOPPED, StopServerResult.SERVER_KILLED });

            command = new Command("StopServer", serverSettingTwo);
            await TestHelper.ExecuteCommandAndAwaitCommandResponse(webSocketTwo, webSocketHandlerTwo, command, "StopServerResponse");

            stopResponse = JsonConvert.DeserializeObject <StopServerResponse>(webSocketHandlerTwo.ReceivedCommand.CommandData.ToString());
            TestHelper.ValiateResponse(stopResponse, new StopServerResult[] { StopServerResult.SERVER_STOPPED, StopServerResult.SERVER_KILLED });
        }
        public async Task StartServerAndConnectToTelnet()
        {
            ClientWebSocket  webSocket        = new ClientWebSocket();
            WebSocketHandler webSocketHandler = new WebSocketHandler(webSocket);
            await webSocket.ConnectAsync(new Uri("ws://localhost:80/ws"), CancellationToken.None);

            await TestHelper.Login("User", "Passwort1$", webSocket, webSocketHandler);

            ServerSetting serverSettings = TestHelper.GenerateNewServerSetting();
            Command       command        = new Command("AddServerSetting", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ModifySettingsResponse modifyResponse = JsonConvert.DeserializeObject <ModifySettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(modifyResponse, ModifySettingsResult.SETTING_ADDED);

            command = new Command("GetServerSettingsOfLoggedInUser", null);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            GetSettingsResponse getResponse = JsonConvert.DeserializeObject <GetSettingsResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(getResponse, GetSettingsResult.OK);

            bool foundServerSetting = false;

            foreach (var item in getResponse.ServerSettings)
            {
                if (serverSettings.WorldGenSeed == item.WorldGenSeed)
                {
                    serverSettings     = item;
                    foundServerSetting = true;
                    break;
                }
            }
            if (!foundServerSetting)
            {
                Assert.Fail("Added ServerSettingsId not found in response");
            }

            command = new Command("StartServer", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            StartServerResponse startResponse = JsonConvert.DeserializeObject <StartServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(startResponse, StartServerResult.SERVER_STARTED);

            command = new Command("ConnectTelnet", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitResponse(webSocket, webSocketHandler, command);

            ConnectTelnetResponse connectResponse = JsonConvert.DeserializeObject <ConnectTelnetResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(connectResponse, ConnectTelnetResult.OK);

            byte[] buffer = new byte[1024 * 4];
            int    receivedTelnetMessages = 0;

            for (int i = 0; receivedTelnetMessages < 1; i++)
            {
                await webSocketHandler.ExtractCompleteMessage(buffer);

                if (webSocketHandler.ReceivedCommand.CommandName == "OnTelnetReceived")
                {
                    Console.WriteLine(webSocketHandler.ReceivedCommand.CommandData.ToString());
                    Trace.Write(webSocketHandler.ReceivedCommand.CommandData.ToString());
                    receivedTelnetMessages++;
                }
                else
                {
                    Console.WriteLine("*** NO TELNET MESSAGE ***");
                }
            }

            command = new Command("StopServer", serverSettings);
            await TestHelper.ExecuteCommandAndAwaitCommandResponse(webSocket, webSocketHandler, command, "StopServerResponse");

            StopServerResponse stopResponse = JsonConvert.DeserializeObject <StopServerResponse>(webSocketHandler.ReceivedCommand.CommandData.ToString());

            TestHelper.ValiateResponse(stopResponse, new StopServerResult[] { StopServerResult.SERVER_STOPPED, StopServerResult.SERVER_KILLED });
        }