Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created November 16, 2022 23:43
Embed
What would you like to do?
[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