Example #1
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);
        }
Example #2
0
        public async Task RemoveServer(string id)
        {
            _runningServers.TryRemove(id, out var server);
            if (server != null)
            {
                await server.StopServer();
            }
            var buildPath  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var serverPath = Path.Combine(buildPath, id);

            Directory.Delete(serverPath, true);
            await _repo.RemoveServer(id);
        }
Example #3
0
        public R.ResultVm <bool> RemoveServer(string name)
        {
            var result = new R.ResultVm <bool>().FromEmptyFailure();

            Demand <string> .That(name, "name").HasNonEmptyValue().Result(result);

            if (result.Errors.Count == 0)
            {
                try
                {
                    return(new ResultVm <bool>().FromSuccessObject(_repo.RemoveServer(name)));
                }
                catch (Exception ex)
                {
                    return(new ResultVm <bool>().FromException(ex));
                }
            }

            return(result);
        }