public void StartAdbServer_StartsWhenNotAlreadyRunning() { _adbServer.GetStatus().Returns(new AdbServerStatus { IsRunning = false }); _adbServer.StartServer("", false).ReturnsForAnyArgs(StartServerResult.Started); _environmentServiceMock.GetEnvironmentVariable("ANDROID_SDK_ROOT").Returns(@"C:\android-sdk"); _fileSystemMock.AddFile(@"C:\android-sdk\platform-tools\adb.exe", MockFileData.NullObject); var started = _adbService.EnsureAdbServerRunning(); Assert.True(started); }
public bool EnsureAdbServerRunning() { var status = _adbServer.GetStatus(); if (status.IsRunning == false) { var androidSdkRoot = _environmentService.GetEnvironmentVariable("ANDROID_SDK_ROOT"); var adbPath = _fileSystem.Path.Combine(androidSdkRoot, "platform-tools", "adb.exe"); if (_fileSystem.File.Exists(adbPath)) { var startResult = _adbServer.StartServer(adbPath, restartServerIfNewer: false); return(startResult == StartServerResult.Started); } } return(true); }