Created
November 14, 2011 21:14
-
-
Save rdingwall/1365189 to your computer and use it in GitHub Desktop.
Tests for my URI ctor patch for System.Net.FtpClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.FtpClient; | |
using NUnit.Framework; | |
namespace System.Net.FtpClient.Tests | |
{ | |
public class FtpClientTests | |
{ | |
[TestFixture] | |
public class when_constructing | |
{ | |
[Test] | |
public void It_should_set_the_port_to_21_when_no_port_is_specified() | |
{ | |
var uri = new Uri("ftp://@testhost"); | |
Assert.AreEqual(21, new FtpClient(uri).Port); | |
} | |
[Test] | |
public void It_should_set_the_server() | |
{ | |
var uri = new Uri("ftp://testuser:testpass@testhost"); | |
Assert.AreEqual("testhost", new FtpClient(uri).Server); | |
} | |
[Test] | |
public void It_should_set_the_port() | |
{ | |
var uri = new Uri("ftp://testhost:999"); | |
Assert.AreEqual(999, new FtpClient(uri).Port); | |
} | |
[Test] | |
public void It_should_set_the_username() | |
{ | |
var uri = new Uri("ftp://testuser:testpass@testhost"); | |
Assert.AreEqual("testuser", new FtpClient(uri).Username); | |
} | |
[Test] | |
public void It_should_set_the_password() | |
{ | |
var uri = new Uri("ftp://testuser:testpass@testhost"); | |
Assert.AreEqual("testpass", new FtpClient(uri).Password); | |
} | |
[Test] | |
public void It_should_set_the_ftp_mode_if_the_scheme_is_ftps() | |
{ | |
var uri = new Uri("FTPS://testhost"); | |
Assert.AreEqual(FtpSslMode.Explicit, new FtpClient(uri).SslMode); | |
} | |
[Test] | |
public void It_should_not_use_ssl_when_the_scheme_is_ftp() | |
{ | |
var uri = new Uri("ftp://testhost"); | |
Assert.AreEqual(FtpSslMode.None, new FtpClient(uri).SslMode); | |
} | |
[Test] | |
public void It_should_throw_an_exception_when_the_scheme_is_not_ftp_or_ftps() | |
{ | |
var uri = new Uri("http://testhost"); | |
Assert.Throws<ArgumentException>(() => new FtpClient(uri)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment