Skip to content

Instantly share code, notes, and snippets.

@maiconheck
Last active June 20, 2023 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maiconheck/90401c530db8db613ae8e71e1f0588b6 to your computer and use it in GitHub Desktop.
Save maiconheck/90401c530db8db613ae8e71e1f0588b6 to your computer and use it in GitHub Desktop.
[Trait("Category", nameof(Domain))]
public class AddressTest
{
[Theory]
[InlineData("79074-047")]
[InlineData("29725-972")]
public void Address_ValidZipCode_Valid(string zipCode)
{
Assert.DoesNotThrows(() => new Address(zipCode, "Rua Júlio de Castilhos", 1234, "Centro"));
}
[Theory]
[InlineData("9074-047")]
[InlineData("64013-51")]
[InlineData("29725972")]
[InlineData("169315-318")]
[InlineData("86035-5263")]
public void Address_InvalidZipCode_Invalid(string zipCode)
{
Assert.Throws<ArgumentException>(() => new Address(zipCode, "Rua Júlio de Castilhos", 1234, "Centro"));
}
[Theory]
[InlineData("Rua Júlio de Castilhos")]
[InlineData("Rua A")]
public void Address_ValidStreet_Valid(string street)
{
Assert.DoesNotThrows(() => new Address("86035-526", street, 1234, "Centro"));
}
[Theory]
[InlineData("")]
[InlineData(" ")]
public void Address_InvalidStreet_Invalid(string street)
{
Assert.Throws<ArgumentNullException>(() => new Address("86035-526", street, 1234, "Centro"));
}
[Theory]
[InlineData(1)]
[InlineData(123)]
public void Address_ValidNumber_Valid(int number)
{
Assert.DoesNotThrows(() => new Address("86035-526", "Rua Júlio de Castilhos", number, "Centro"));
}
[Theory]
[InlineData(0)]
[InlineData(-1)]
public void Address_InvalidNumber_Invalid(int number)
{
Assert.Throws<ArgumentException>(() => new Address("86035-526", "Rua Júlio de Castilhos", number, "Centro"));
}
[Theory]
[InlineData("Centro")]
public void Address_ValidNeighborhood_Valid(string neighborhood)
{
Assert.DoesNotThrows(() => new Address("86035-526", "Rua Júlio de Castilhos", 1234, neighborhood));
}
[Theory]
[InlineData("")]
[InlineData(" ")]
public void Address_InvalidNeighborhood_Invalid(string neighborhood)
{
Assert.Throws<ArgumentNullException>(() => new Address("86035-526", "Rua Júlio de Castilhos", 1234, neighborhood));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment