Beispiel #1
0
        public async Task StartServerById(string id, int maxRamMB, int minRamMB)
        {
            var server = await _repo.GetServerById(id);

            if (server == null)
            {
                // TODO: Add error handling here
                return;
            }
            if (_runningServers.ContainsKey(id))
            {
                // TODO: Add error handling here
                return;
            }

            var serverProcess = new ServerProcess(server.Id, maxRamMB, minRamMB);

            _runningServers.TryAdd(server.Id, serverProcess);
            var pId = serverProcess.StartServer(_logger, _angularHub);

            server.MaxRamMB  = maxRamMB;
            server.MinRamMB  = minRamMB;
            server.ProcessId = pId;
            server.IsRunning = true;
            server.TimesRan++;
            await _repo.UpsertServer(server);

            return;
        }
Beispiel #2
0
        public async Task <IActionResult> GetServerById([Required] string id)
        {
            var server = await _repo.GetServerById(id);

            var serverDTO = _mapper.Map <MinecraftServerDTO>(server);

            return(Ok(serverDTO));
        }
Beispiel #3
0
        public async Task GetServerByIdTest()
        {
            // Arrange
            await _repo.AddServer(fooServer1);

            // Act
            var server = await _repo.GetServerById(fooServer1.Id);

            await _repo.RemoveServer(fooServer1.Id);

            // Assert
            Assert.NotNull(server);
            Assert.Equal(fooServer1.Id, server.Id);
        }