예제 #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;
        }
예제 #2
0
        public async Task UpsertServerTest()
        {
            // Arrange
            await _repo.AddServer(fooServer1);

            fooServer1.MinecraftVersion = "1.13.2";

            // Act
            await _repo.UpsertServer(fooServer1);

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

            await _repo.RemoveServer(fooServer1.Id);

            // Assert
            Assert.NotNull(server);
            Assert.Equal("1.13.2", server.MinecraftVersion);
        }