Esempio n. 1
0
    public void AInitialize(Action p_callbackFinish)
    {
        _localConnector = new LocalConnector();
        _localConnector.AInitialize();

        InitializeDataAccessObjects();
    }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        /// <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);
        }
Esempio n. 7
0
 public void UploadFolder_Throws_ArgumentNullException(string localFolderPath, string remoteFolderPath)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.UploadFolder(localFolderPath, remoteFolderPath));
 }
Esempio n. 8
0
 public void UploadFile_Throws_ArgumentNullException(string localFilePath, string remoteFilePath, string remoteFileName)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.UploadFile(localFilePath, remoteFilePath, remoteFileName));
 }
Esempio n. 9
0
 public void UploadFile_Throws_FileNotFoundException(string localFilePath, string remoteFilePath, string remoteFileName)
 {
     Assert.Throws <FileNotFoundException>(() => LocalConnector.UploadFile(localFilePath, remoteFilePath, remoteFileName));
 }
Esempio n. 10
0
 public void Download_Throws_ArgumentNullException(string uri, string savePath)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.Download(new Uri(uri), savePath));
 }
Esempio n. 11
0
 public void GetFile_Local_Throws_ArgumentNullException(string path, string folder)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.GetFile(path, folder));
 }
Esempio n. 12
0
 public string[] GetFiles_Local_DoesNotThrow(bool recursive)
 {
     return(LocalConnector.GetFiles(SamplesScriptFolder, recursive).ToList().Select(x => Path.GetFileName(x)).OrderBy(x => x).ToArray());
 }
Esempio n. 13
0
 public void DeleteFolder_Throws_ArgumentNullException(string path, string folder)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.DeleteFolder(path, folder));
 }
Esempio n. 14
0
 public void CreateFile_Throws_FileNotFoundException(string local, string remote)
 {
     Assert.Throws <FileNotFoundException>(() => LocalConnector.CreateFile(local, remote));
 }
Esempio n. 15
0
 public void DeleteFile_Throws_ArgumentNullException(string local, string remote)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.DeleteFile(local, remote));
 }
Esempio n. 16
0
 public void CountFiles_Throws_ArgumentNullException(string path)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.CountFiles(path));
 }
Esempio n. 17
0
        public string GetFile_Local_DoesNotThrow(string folder, bool recursive)
        {
            var found = LocalConnector.GetFile(SamplesScriptFolder, folder, recursive);

            return(string.IsNullOrEmpty(found) ? found : Path.GetFileName(found));
        }
Esempio n. 18
0
 public void GetFolders_Local_Throws_ArgumentNullException(string path)
 {
     Assert.Throws <ArgumentNullException>(() => LocalConnector.GetFolders(path));
 }
Esempio n. 19
0
 public void GetFile_Throws_ArgumentInvalidException(string path, string file)
 {
     Assert.Throws <ArgumentInvalidException>(() => LocalConnector.GetFile(path, file));
 }
Esempio n. 20
0
 public override void TearDown()
 {
     RemoteConnector.Dispose();
     LocalConnector.Dispose();
     base.TearDown();
 }
Esempio n. 21
0
 public void UploadFolder_Throws_DirectoryNotFoundException(string localFolderPath, string remoteFolderPath)
 {
     Assert.Throws <DirectoryNotFoundException>(() => LocalConnector.UploadFolder(localFolderPath, remoteFolderPath));
 }
Esempio n. 22
0
 public void CopyFile_Throws_ArgumentInvalidException(string uri, string remote)
 {
     Assert.Throws <ArgumentInvalidException>(() => LocalConnector.CopyFile(new Uri(uri), remote));
 }
Esempio n. 23
0
 public int CountFiles_DoesNotThrows(string path, string folder, bool recursive)
 {
     return(LocalConnector.CountFiles(Path.Combine(path, folder), recursive));
 }
Esempio n. 24
0
 public int CountFiles_Local_DoesNotThrow(bool recursive)
 {
     return(LocalConnector.CountFiles(SamplesScriptFolder, recursive));
 }