Esempio n. 1
0
        public void SimpleFTPClientShouldConnectToServerSuccessfully()
        {
            var client = new SimpleFTPClient(hostname, port);

            // It should crash if client is not able to connect
            client.ReceiveFileList("strange_test_path");
        }
Esempio n. 2
0
        public void SimpleFTPClientShouldReceiveCorrectFileList()
        {
            var path           = ".SimpleFTPTEST_TEST_";
            var fullpath       = Path.Combine(Path.GetTempPath() + path);
            var actualFileList = this.CreateTestDirectory(fullpath);

            var client = new SimpleFTPClient(hostname, port);
            var files  = client.ReceiveFileList(path);

            Comparison <FileMetaInfo> comparison =
                (item1, item2) =>
            {
                if (item1.IsDirectory == item2.IsDirectory)
                {
                    return(String.Compare(
                               item1.Name, item2.Name, StringComparison.Ordinal));
                }
                else
                {
                    return(item1.IsDirectory ? -1 : 1);
                }
            };

            Assert.That(files, Is.EquivalentTo(actualFileList).Using(comparison));
        }
Esempio n. 3
0
        public void SimpleFTPClientShouldReceiveCorrectFile()
        {
            var testFilePath = Path.GetFileName(Path.GetTempFileName());
            var fileSavePath = Path.GetTempFileName();

            var client = new SimpleFTPClient(hostname, port);

            Assert.IsTrue(client.ReceiveFile(testFilePath, fileSavePath));

            var testFileContent =
                new StreamReader(File.OpenRead(Path.GetTempPath() + testFilePath)).ReadToEnd();
            var receivedFileContent =
                new StreamReader(File.OpenRead(fileSavePath)).ReadToEnd();

            Assert.AreEqual(testFileContent, receivedFileContent);
        }