-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
121 additions
and
113 deletions.
There are no files selected for viewing
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
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
110 changes: 57 additions & 53 deletions
110
src/Svea.WebPay.SDK.Tests/UnitTests/EmailAddressTests.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,71 @@ | ||
using System; | ||
|
||
using Xunit; | ||
|
||
namespace Svea.WebPay.SDK.Tests.UnitTests | ||
{ | ||
public class EmailAddressTests | ||
{ | ||
private readonly string validAddress = "leia.ahlstrom@svea.com"; | ||
public class EmailAddressTests | ||
{ | ||
private readonly string validAddress = "leia.ahlstrom@svea.com"; | ||
|
||
|
||
[Fact] | ||
public void AddressValue_IsSetCorrectly_WhenGivenValidAddressString() | ||
{ | ||
//ACT | ||
var addressObject = new EmailAddress(this.validAddress); | ||
[Fact] | ||
public void AddressValue_IsSetCorrectly_WhenGivenValidAddressString() | ||
{ | ||
//ACT | ||
var addressObject = new EmailAddress(this.validAddress); | ||
|
||
//ASSERT | ||
Assert.Equal(this.validAddress, addressObject.ToString()); | ||
} | ||
//ASSERT | ||
Assert.Equal(this.validAddress, addressObject.ToString()); | ||
} | ||
|
||
|
||
[Theory] | ||
[InlineData("email@example.com")] | ||
[InlineData("firstname.lastname@example.com")] | ||
[InlineData("email@subdomain.example.com")] | ||
[InlineData("firstname+lastname@example.com")] | ||
[InlineData("email@123.123.123.123")] | ||
[InlineData("\"email\"@example.com")] | ||
[InlineData("1234567890@example.com")] | ||
[InlineData("email@example-one.com")] | ||
[InlineData("email@example.name")] | ||
[InlineData("email@example.museum")] | ||
[InlineData("email@example.co.jp")] | ||
[InlineData("firstname-lastname@example.com")] | ||
public void CreateNewEmailAddress_DoesNotThrow_WhenGivenValidAddressString(string address) | ||
{ | ||
//ACT | ||
var ex = Record.Exception(() => new EmailAddress(address)); | ||
[Theory] | ||
[InlineData("a@a.com")] | ||
[InlineData("a_@a.com")] | ||
[InlineData("a_b@a.com")] | ||
[InlineData("email@example.com")] | ||
[InlineData("firstname.lastname@example.com")] | ||
[InlineData("email@subdomain.example.com")] | ||
[InlineData("firstname+lastname@example.com")] | ||
[InlineData("email@123.123.123.123")] | ||
[InlineData("\"email\"@example.com")] | ||
[InlineData("1234567890@example.com")] | ||
[InlineData("email@example-one.com")] | ||
[InlineData("email@example.name")] | ||
[InlineData("email@example.museum")] | ||
[InlineData("email@example.co.jp")] | ||
[InlineData("firstname-lastname@example.com")] | ||
public void CreateNewEmailAddress_DoesNotThrow_WhenGivenValidAddressString(string address) | ||
{ | ||
//ACT | ||
var ex = Record.Exception(() => new EmailAddress(address)); | ||
|
||
//ASSERT | ||
Assert.Null(ex); | ||
} | ||
//ASSERT | ||
Assert.Null(ex); | ||
} | ||
|
||
|
||
[Theory] | ||
[InlineData("plainaddress")] | ||
[InlineData("#@%^%#$@#$@#.com")] | ||
[InlineData("@example.com")] | ||
[InlineData("Joe Smith <email@example.com>")] | ||
[InlineData("email.example.com")] | ||
[InlineData("email@example@example.com")] | ||
[InlineData(".email@example.com")] | ||
[InlineData("email.@example.com")] | ||
[InlineData("email..email@example.com")] | ||
[InlineData("あいうえお@example.com")] | ||
[InlineData("email@example.com (Joe Smith)")] | ||
[InlineData("email@example")] | ||
[InlineData("email@-example.com")] | ||
[InlineData("email@example..com")] | ||
[InlineData("Abc..123@example.com")] | ||
public void ThrowsArgumentException_WhenGivenInvalidAddressString(string address) | ||
{ | ||
//ASSERT | ||
Assert.Throws<ArgumentException>("emailAddress", () => new EmailAddress(address)); | ||
} | ||
} | ||
[Theory] | ||
[InlineData("plainaddress")] | ||
[InlineData("#@%^%#$@#$@#.com")] | ||
[InlineData("@example.com")] | ||
[InlineData("Joe Smith <email@example.com>")] | ||
[InlineData("email.example.com")] | ||
[InlineData("email@example@example.com")] | ||
[InlineData(".email@example.com")] | ||
[InlineData("email.@example.com")] | ||
[InlineData("email..email@example.com")] | ||
[InlineData("あいうえお@example.com")] | ||
[InlineData("email@example.com (Joe Smith)")] | ||
[InlineData("email@example")] | ||
[InlineData("email@-example.com")] | ||
[InlineData("email@example..com")] | ||
[InlineData("Abc..123@example.com")] | ||
public void ThrowsArgumentException_WhenGivenInvalidAddressString(string address) | ||
{ | ||
//ASSERT | ||
Assert.Throws<ArgumentException>("emailAddress", () => new EmailAddress(address)); | ||
} | ||
} | ||
} |
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