public void InvalidPassword() { FtpConnectionData connectionData = new FtpConnectionData(); connectionData.Credentials = new NetworkCredential(Username, Password + "xxx"); connectionData.Host = Host; using (IFtpSession session = new FtpSession(new FtpChannelFactoryUsingSockets(), new FtpCommunicator(), new WindowsFileSystem())) { var ex = Assert.Throws <FtpException>(delegate { session.BeginSession(connectionData); }); Assert.AreEqual("Could not log in to the FTP server: 530 User cannot log in.", ex.Message); } }
private static void FtpAction(Action <IFtpSession> action) { FtpConnectionData connectionData = new FtpConnectionData(); connectionData.Credentials = new NetworkCredential(Username, Password); connectionData.Host = Host; connectionData.Port = Port; using (IFtpSession session = new FtpSession(new FtpChannelFactoryUsingSockets(), new FtpCommunicator(), new WindowsFileSystem())) { session.BeginSession(connectionData); action(session); } }