Skip to content

Commit

Permalink
[chore] Update create_verify unit test with better invalid address (#540
Browse files Browse the repository at this point in the history
)

- Update create_verify unit test with better invalid address
- Re-record cassettes as needed
  • Loading branch information
nwithan8 committed Jan 5, 2024
1 parent 26c6c16 commit b144cde
Show file tree
Hide file tree
Showing 15 changed files with 469 additions and 161 deletions.
31 changes: 25 additions & 6 deletions EasyPost.Tests/ServicesTests/AddressServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using EasyPost.Tests._Utilities;
using EasyPost.Tests._Utilities.Attributes;
using EasyPost.Utilities.Internal.Attributes;
using EasyPost.Utilities.Internal.Extensions;
using Xunit;

namespace EasyPost.Tests.ServicesTests
Expand Down Expand Up @@ -41,14 +42,23 @@ public async Task TestCreateVerify()
UseVCR("create_verify");

Dictionary<string, object> addressData = Fixtures.IncorrectAddress;

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

Assert.IsType<Address>(address);
Assert.Null(address.Verifications.Delivery);
Assert.Null(address.Verifications.Zip4);

// Creating with verify would make the address and perform verifications
// internally, we're just checking for the presence of "verify" in the dictionary, so the value doesn't matter
addressData.Add("verify", true);

Address address = await Client.Address.Create(addressData);
address = await Client.Address.Create(addressData);

Assert.IsType<Address>(address);
Assert.StartsWith("adr_", address.Id);
Assert.Equal("417 MONTGOMERY ST FL 5", address.Street1);
Assert.NotNull(address.Verifications.Delivery);
Assert.NotNull(address.Verifications.Zip4);
}

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

Dictionary<string, object> addressData = Fixtures.IncorrectAddress;

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

Assert.IsType<Address>(address);
Assert.Null(address.Verifications.Delivery);
Assert.Null(address.Verifications.Zip4);

// Creating with verify would make the address and perform verifications
// internally, we're just checking for the presence of "verify" in the dictionary, so the value doesn't matter
addressData.Add("verify", new List<bool> { true });

Address address = await Client.Address.Create(addressData);
address = await Client.Address.Create(addressData);

Assert.IsType<Address>(address);
Assert.StartsWith("adr_", address.Id);
Assert.Equal("417 MONTGOMERY ST FL 5", address.Street1);
Assert.NotNull(address.Verifications.Delivery);
Assert.NotNull(address.Verifications.Zip4);
}

[Fact]
Expand Down
16 changes: 12 additions & 4 deletions EasyPost.Tests/ServicesTests/WithParameters/AddressServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,23 @@ public async Task TestCreateVerify()
UseVCR("create_verify");

Dictionary<string, object> fixture = Fixtures.IncorrectAddress;
fixture["verify"] = true;

Parameters.Address.Create parameters = Fixtures.Parameters.Addresses.Create(fixture);

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

Assert.IsType<Address>(address);
Assert.StartsWith("adr_", address.Id);
Assert.Equal("417 MONTGOMERY ST FL 5", address.Street1);
Assert.Null(address.Verifications.Delivery);
Assert.Null(address.Verifications.Zip4);

// Creating with verify would make the address and perform verifications
parameters.Verify = true;

address = await Client.Address.Create(parameters);

Assert.IsType<Address>(address);
Assert.NotNull(address.Verifications.Delivery);
Assert.NotNull(address.Verifications.Zip4);
}

[Fact]
Expand Down
76 changes: 63 additions & 13 deletions EasyPost.Tests/cassettes/net/address_service/create_verify.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b144cde

Please sign in to comment.