public void AInitialize(Action p_callbackFinish) { _localConnector = new LocalConnector(); _localConnector.AInitialize(); InitializeDataAccessObjects(); }
public void Download_DoesNotThrow(string uri, string file) { var filePath = Path.Combine(TempScriptFolder, file); Assert.AreEqual(filePath, LocalConnector.Download(new Uri(uri), TempScriptFolder)); Assert.IsTrue(File.Exists(filePath)); }
/// <summary> /// Connects to a local instance /// </summary> /// <param name="targetConnector">Target connector</param> /// <param name="token">Token</param> /// <returns>Client synchronizer if successful, otherwise "null"</returns> public static IClientSynchronizer ConnectToLocalInstance(ILocalConnector targetConnector, string token) { if (targetConnector == null) { throw new ArgumentNullException(nameof(targetConnector)); } ILocalConnector connector = new LocalConnector((_) => true); IClientSynchronizer ret = new ClientSynchronizer(connector.ConnectToLocal(targetConnector), token); ret.AddConnector(connector); return(ret); }
public string GetFile_DoesNotThrow(string path, string file, bool recursive) { var f = LocalConnector.GetFile(path, file, recursive); if (f == null) { return(null); } else { return(f.Name); } }
public int RunCommand_Local_DoesNotThrow(string command) { if (Core.Utils.CurrentOS == OS.WIN) { command = string.Format("wsl {0}", command); } //TODO: on windows, test if the wsl is installed because wsl -e will be used to test linux commands and windows ones in one step if don't, throw an exception var lres = LocalConnector.RunCommand(command); Assert.IsNotNull(lres.response); return(lres.code); }
/// <summary> /// Create server /// </summary> /// <param name="networkPort">Server network port</param> /// <param name="timeoutTime">Timeout time in seconds</param> /// <returns>Server if successful, otherwise "null"</returns> public static IServerSynchronizer Create(ushort networkPort, uint timeoutTime) { if (networkPort < 1) { throw new ArgumentException("Network port can't be smaller than 1."); } IServerSynchronizer ret = null; if (NetworkLibrary.Initialize()) { Host server_host = null; IConnector[] connectors = new IConnector[2]; try { server_host = new Host(); Address address = new Address { Port = networkPort }; server_host.Create(address, (int)Library.maxPeers, 0); ret = new ServerSynchronizer(); bool on_handle_peer_connection_attempt(IPeer peer) => !ret.Bans.IsPeerBanned(peer, out _); connectors[0] = new LocalConnector(on_handle_peer_connection_attempt); connectors[1] = new ENetConnector(server_host, networkPort, timeoutTime, on_handle_peer_connection_attempt); foreach (IConnector connector in connectors) { ret.AddConnector(connector); } } catch (Exception e) { Console.Error.WriteLine(e); server_host?.Dispose(); foreach (IConnector connector in connectors) { connector?.Dispose(); } ret?.Dispose(); NetworkLibrary.Deinitialize(); } } return(ret); }
public void UploadFolder_Throws_ArgumentNullException(string localFolderPath, string remoteFolderPath) { Assert.Throws <ArgumentNullException>(() => LocalConnector.UploadFolder(localFolderPath, remoteFolderPath)); }
public void UploadFile_Throws_ArgumentNullException(string localFilePath, string remoteFilePath, string remoteFileName) { Assert.Throws <ArgumentNullException>(() => LocalConnector.UploadFile(localFilePath, remoteFilePath, remoteFileName)); }
public void UploadFile_Throws_FileNotFoundException(string localFilePath, string remoteFilePath, string remoteFileName) { Assert.Throws <FileNotFoundException>(() => LocalConnector.UploadFile(localFilePath, remoteFilePath, remoteFileName)); }
public void Download_Throws_ArgumentNullException(string uri, string savePath) { Assert.Throws <ArgumentNullException>(() => LocalConnector.Download(new Uri(uri), savePath)); }
public void GetFile_Local_Throws_ArgumentNullException(string path, string folder) { Assert.Throws <ArgumentNullException>(() => LocalConnector.GetFile(path, folder)); }
public string[] GetFiles_Local_DoesNotThrow(bool recursive) { return(LocalConnector.GetFiles(SamplesScriptFolder, recursive).ToList().Select(x => Path.GetFileName(x)).OrderBy(x => x).ToArray()); }
public void DeleteFolder_Throws_ArgumentNullException(string path, string folder) { Assert.Throws <ArgumentNullException>(() => LocalConnector.DeleteFolder(path, folder)); }
public void CreateFile_Throws_FileNotFoundException(string local, string remote) { Assert.Throws <FileNotFoundException>(() => LocalConnector.CreateFile(local, remote)); }
public void DeleteFile_Throws_ArgumentNullException(string local, string remote) { Assert.Throws <ArgumentNullException>(() => LocalConnector.DeleteFile(local, remote)); }
public void CountFiles_Throws_ArgumentNullException(string path) { Assert.Throws <ArgumentNullException>(() => LocalConnector.CountFiles(path)); }
public string GetFile_Local_DoesNotThrow(string folder, bool recursive) { var found = LocalConnector.GetFile(SamplesScriptFolder, folder, recursive); return(string.IsNullOrEmpty(found) ? found : Path.GetFileName(found)); }
public void GetFolders_Local_Throws_ArgumentNullException(string path) { Assert.Throws <ArgumentNullException>(() => LocalConnector.GetFolders(path)); }
public void GetFile_Throws_ArgumentInvalidException(string path, string file) { Assert.Throws <ArgumentInvalidException>(() => LocalConnector.GetFile(path, file)); }
public override void TearDown() { RemoteConnector.Dispose(); LocalConnector.Dispose(); base.TearDown(); }
public void UploadFolder_Throws_DirectoryNotFoundException(string localFolderPath, string remoteFolderPath) { Assert.Throws <DirectoryNotFoundException>(() => LocalConnector.UploadFolder(localFolderPath, remoteFolderPath)); }
public void CopyFile_Throws_ArgumentInvalidException(string uri, string remote) { Assert.Throws <ArgumentInvalidException>(() => LocalConnector.CopyFile(new Uri(uri), remote)); }
public int CountFiles_DoesNotThrows(string path, string folder, bool recursive) { return(LocalConnector.CountFiles(Path.Combine(path, folder), recursive)); }
public int CountFiles_Local_DoesNotThrow(bool recursive) { return(LocalConnector.CountFiles(SamplesScriptFolder, recursive)); }