Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created November 16, 2022 23:43
Show Gist options
  • Save dcomartin/d2f1075da00e11e1c22d2c3e7993c7c7 to your computer and use it in GitHub Desktop.
Save dcomartin/d2f1075da00e11e1c22d2c3e7993c7c7 to your computer and use it in GitHub Desktop.
[Fact]
public void ThrowIfNull()
{
Assert.Throws<ArgumentNullException>(() => new Username(null));
}
[Fact]
public void ThrowIfEmpty()
{
Assert.Throws<ArgumentNullException>(() => new Username(string.Empty));
}
[Fact]
public void ReturnString()
{
string username = Guid.NewGuid().ToString();
Assert.Equal(username, new Username(username).ToString());
}
[Fact]
public void ThrowOnDefault()
{
Assert.Throws<InvalidCastException>(() => default(Username).ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment