Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public class MyService
)
);

var apiResponse = await _client.Payments.CreatePayout(
var apiResponse = await _client.Payouts.CreatePayout(
payoutRequest,
idempotencyKey: Guid.NewGuid().ToString()
);
Expand Down
9 changes: 5 additions & 4 deletions src/TrueLayer/Common/Address.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ public record Address
/// </summary>
public Address(
string city,
string state,
string? state,
string zip,
string countryCode,
string addressLine1,
string? addressLine2 = null)
{
AddressLine1 = addressLine1.NotNullOrWhiteSpace(nameof(addressLine1));
AddressLine2 = addressLine2.NotEmptyOrWhiteSpace(nameof(addressLine2));
City = city.NotNullOrWhiteSpace(nameof(city));
State = state.NotNullOrWhiteSpace(nameof(state));
Zip = zip.NotNullOrWhiteSpace(nameof(zip));
CountryCode = countryCode.NotNullOrWhiteSpace(nameof(countryCode));

AddressLine2 = addressLine2.NotEmptyOrWhiteSpace(nameof(addressLine2));
State = state.NotEmptyOrWhiteSpace(nameof(state));
}

/// <summary>
Expand All @@ -39,7 +40,7 @@ public Address(
/// <summary>
/// Gets the name of the country / stat.
/// </summary>
public string State { get; }
public string? State { get; }

/// <summary>
/// Gets the zip code or postal code
Expand Down
20 changes: 15 additions & 5 deletions test/TrueLayer.Tests/Common/AddressTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void New_address_throws_if_address_line_1_empty_or_whitespace(string addr
[Theory]
[InlineData("")]
[InlineData(" ")]
public void New_address_throws_if_city_null_or_empty(string city)
public void New_address_throws_if_city_is_empty_or_whitespace(string city)
{
Assert.Throws<ArgumentException>("city",
() => new Address(city, "state", "zip", "country Code", "addressLine1"));
Expand All @@ -27,16 +27,21 @@ public void New_address_throws_if_city_null_or_empty(string city)
[Theory]
[InlineData("")]
[InlineData(" ")]
public void New_address_throws_if_state_null_or_empty(string state)
public void New_address_throws_if_state_is_empty_or_whitespace(string state)
{
Assert.Throws<ArgumentException>("state",
() => new Address("city", state, "zip", "country Code", "addressLine1"));
}

[Fact]
public void New_address_is_created_successfully_if_state_is_null() =>
// ReSharper disable once ObjectCreationAsStatement
new Address("city", state: null, "zip", "countryCode", "addressLine1", "addressLine2");

[Theory]
[InlineData("")]
[InlineData(" ")]
public void New_address_throws_if_zip_null_or_empty(string zip)
public void New_address_throws_if_zip_is_empty_or_whitespace(string zip)
{
Assert.Throws<ArgumentException>("zip",
() => new Address("city", "state", zip, "country Code", "addressLine1"));
Expand All @@ -45,7 +50,7 @@ public void New_address_throws_if_zip_null_or_empty(string zip)
[Theory]
[InlineData("")]
[InlineData(" ")]
public void New_address_throws_if_country_code_null_or_empty(string countryCode)
public void New_address_throws_if_country_code_is_empty_or_whitespace(string countryCode)
{
Assert.Throws<ArgumentException>("countryCode",
() => new Address("city", "state", "zip", countryCode, "addressLine1"));
Expand All @@ -54,9 +59,14 @@ public void New_address_throws_if_country_code_null_or_empty(string countryCode)
[Theory]
[InlineData("")]
[InlineData(" ")]
public void New_address_throws_if_address_line_2_null_or_empty(string addressLine2)
public void New_address_throws_if_address_line_2_is_empty_or_whitespace(string addressLine2)
{
Assert.Throws<ArgumentException>("addressLine2",
() => new Address("city", "state", "zip", "countryCode", "addressLine1", addressLine2));
}

[Fact]
public void New_address_is_created_successfully_if_address_line_2_is_null() =>
// ReSharper disable once ObjectCreationAsStatement
new Address("city", "state", "zip", "countryCode", "addressLine1", addressLine2: null);
}
Loading