Skip to content

Commit b144cde

Browse files
authored
[chore] Update create_verify unit test with better invalid address (#540)
- Update create_verify unit test with better invalid address - Re-record cassettes as needed
1 parent 26c6c16 commit b144cde

File tree

15 files changed

+469
-161
lines changed

15 files changed

+469
-161
lines changed

EasyPost.Tests/ServicesTests/AddressServiceTest.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using EasyPost.Tests._Utilities;
66
using EasyPost.Tests._Utilities.Attributes;
77
using EasyPost.Utilities.Internal.Attributes;
8+
using EasyPost.Utilities.Internal.Extensions;
89
using Xunit;
910

1011
namespace EasyPost.Tests.ServicesTests
@@ -41,14 +42,23 @@ public async Task TestCreateVerify()
4142
UseVCR("create_verify");
4243

4344
Dictionary<string, object> addressData = Fixtures.IncorrectAddress;
45+
46+
// Creating normally (without specifying "verify") will make the address, perform no verifications
47+
Address address = await Client.Address.Create(addressData);
48+
49+
Assert.IsType<Address>(address);
50+
Assert.Null(address.Verifications.Delivery);
51+
Assert.Null(address.Verifications.Zip4);
52+
53+
// Creating with verify would make the address and perform verifications
4454
// internally, we're just checking for the presence of "verify" in the dictionary, so the value doesn't matter
4555
addressData.Add("verify", true);
4656

47-
Address address = await Client.Address.Create(addressData);
57+
address = await Client.Address.Create(addressData);
4858

4959
Assert.IsType<Address>(address);
50-
Assert.StartsWith("adr_", address.Id);
51-
Assert.Equal("417 MONTGOMERY ST FL 5", address.Street1);
60+
Assert.NotNull(address.Verifications.Delivery);
61+
Assert.NotNull(address.Verifications.Zip4);
5262
}
5363

5464
[Fact]
@@ -59,14 +69,23 @@ public async Task TestCreateVerifyArray()
5969
UseVCR("create_verify_array");
6070

6171
Dictionary<string, object> addressData = Fixtures.IncorrectAddress;
72+
73+
// Creating normally (without specifying "verify") will make the address, perform no verifications
74+
Address address = await Client.Address.Create(addressData);
75+
76+
Assert.IsType<Address>(address);
77+
Assert.Null(address.Verifications.Delivery);
78+
Assert.Null(address.Verifications.Zip4);
79+
80+
// Creating with verify would make the address and perform verifications
6281
// internally, we're just checking for the presence of "verify" in the dictionary, so the value doesn't matter
6382
addressData.Add("verify", new List<bool> { true });
6483

65-
Address address = await Client.Address.Create(addressData);
84+
address = await Client.Address.Create(addressData);
6685

6786
Assert.IsType<Address>(address);
68-
Assert.StartsWith("adr_", address.Id);
69-
Assert.Equal("417 MONTGOMERY ST FL 5", address.Street1);
87+
Assert.NotNull(address.Verifications.Delivery);
88+
Assert.NotNull(address.Verifications.Zip4);
7089
}
7190

7291
[Fact]

EasyPost.Tests/ServicesTests/WithParameters/AddressServiceTest.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,23 @@ public async Task TestCreateVerify()
4444
UseVCR("create_verify");
4545

4646
Dictionary<string, object> fixture = Fixtures.IncorrectAddress;
47-
fixture["verify"] = true;
48-
4947
Parameters.Address.Create parameters = Fixtures.Parameters.Addresses.Create(fixture);
5048

49+
// Creating normally (without specifying "verify") will make the address, perform no verifications
5150
Address address = await Client.Address.Create(parameters);
5251

5352
Assert.IsType<Address>(address);
54-
Assert.StartsWith("adr_", address.Id);
55-
Assert.Equal("417 MONTGOMERY ST FL 5", address.Street1);
53+
Assert.Null(address.Verifications.Delivery);
54+
Assert.Null(address.Verifications.Zip4);
55+
56+
// Creating with verify would make the address and perform verifications
57+
parameters.Verify = true;
58+
59+
address = await Client.Address.Create(parameters);
60+
61+
Assert.IsType<Address>(address);
62+
Assert.NotNull(address.Verifications.Delivery);
63+
Assert.NotNull(address.Verifications.Zip4);
5664
}
5765

5866
[Fact]

EasyPost.Tests/cassettes/net/address_service/create_verify.json

Lines changed: 63 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EasyPost.Tests/cassettes/net/address_service/create_verify_array.json

Lines changed: 63 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)