Skip to content
Merged
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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
- Adds support for `UspsShipAccount`
- Adds `Tracker.RetrieveBatch` function
- Adds `VerifyCarrier` address param
- Disposes of Luma service after use

## v7.2.0 (2025-06-18)

Expand Down
7 changes: 0 additions & 7 deletions EasyPost.Tests/ClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,6 @@ public void TestThreadSafety()

private const string FakeApikey = "fake_api_key";

[Fact]
public void TestClientDisposal()
{
Client client = new(new ClientConfiguration(FakeApikey));
CustomAssertions.DoesNotThrow(() => client.Dispose());
}

[Fact]
public void TestBaseUrlOverride()
{
Expand Down
16 changes: 16 additions & 0 deletions EasyPost.Tests/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,22 @@ internal static ParameterSets.Tracker.All All(Dictionary<string, object>? fixtur
Carrier = fixture.GetOrNull<string>("carrier"),
};
}

internal static ParameterSets.Tracker.Batch Batch(Dictionary<string, object>? fixture)
{
fixture ??= new Dictionary<string, object>();

return new ParameterSets.Tracker.Batch
{
PageSize = fixture.GetOrNullInt("page_size"),
BeforeId = fixture.GetOrNull<string>("before_id"),
AfterId = fixture.GetOrNull<string>("after_id"),
StartDatetime = fixture.GetOrNull<string>("start_datetime"),
EndDatetime = fixture.GetOrNull<string>("end_datetime"),
TrackingCodes = fixture.GetOrNull<List<string>>("tracking_codes"),
Carrier = fixture.GetOrNull<string>("carrier"),
};
}
}

internal static class Users
Expand Down
1 change: 0 additions & 1 deletion EasyPost.Tests/HttpTests/ClientConfigurationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public class ClientConfigurationTest
public void TestClientConfigurationDisposal()
{
ClientConfiguration configuration = new("not_a_real_api_key");
CustomAssertions.DoesNotThrow(() => configuration.Dispose());
}

[Fact]
Expand Down
1 change: 0 additions & 1 deletion EasyPost.Tests/HttpTests/RequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class RequestTest
public void TestRequestDisposal()
{
Request request = new("https://example.com", "not_a_real_endpoint", Method.Get, ApiVersion.V2, new Dictionary<string, object> { { "key", "value" } }, new Dictionary<string, string> { { "header_key", "header_value" } });
CustomAssertions.DoesNotThrow(() => request.Dispose());
}

[Fact]
Expand Down
1 change: 0 additions & 1 deletion EasyPost.Tests/ServicesTests/ServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void TestServiceDisposal()
Client client = new(new ClientConfiguration("not_a_real_api_key"));

AddressService addressService = client.Address;
CustomAssertions.DoesNotThrow(() => addressService.Dispose());
}

/// <summary>
Expand Down
20 changes: 0 additions & 20 deletions EasyPost.Tests/ServicesTests/TrackerServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,26 +147,6 @@ public async Task TestRetrieve()
Assert.Equal(tracker.Id, retrievedTracker.Id);
}

[Fact]
[CrudOperations.Read]
[Testing.Function]
public async Task TestRetrieveBatch()
{
UseVCR("retrieve_batch");

Tracker tracker = await Client.Tracker.Create(Fixtures.Usps, "EZ1000000001");

List<string> trackingCodes = new() { tracker.TrackingCode };
TrackerCollection trackerCollection = await Client.Tracker.RetrieveBatch(new Dictionary<string, object> { { "tracking_codes", trackingCodes } });

List<Tracker> trackers = trackerCollection.Trackers;

foreach (Tracker singleTracker in trackers)
{
Assert.IsType<Tracker>(singleTracker);
}
}

#endregion

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,28 @@ public async Task TestAllParameterHandOff()
Assert.Equal(filters.Carrier, ((Parameters.Tracker.All)trackerCollection.Filters!).Carrier);
}

[Fact]
[CrudOperations.Read]
[Testing.Function]
public async Task TestRetrieveBatch()
{
UseVCR("retrieve_batch");

Tracker tracker = await Client.Tracker.Create(Fixtures.Usps, "EZ1000000001");

Dictionary<string, object> data = new Dictionary<string, object>() { { "tracking_codes", new List<string> { tracker.TrackingCode } } };
Parameters.Tracker.Batch parameters = Fixtures.Parameters.Trackers.Batch(data);

TrackerCollection trackerCollection = await Client.Tracker.RetrieveBatch(parameters);

List<Tracker> trackers = trackerCollection.Trackers;

foreach (Tracker singleTracker in trackers)
{
Assert.IsType<Tracker>(singleTracker);
}
}

#endregion

#endregion
Expand Down
34 changes: 1 addition & 33 deletions EasyPost.Tests/_Utilities/UnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace EasyPost.Tests._Utilities
/// Base class for all unit tests.
/// Sets up all available client versions for VCR and non-VCR requests.
/// </summary>
public class UnitTest : IDisposable
public class UnitTest
{
private readonly TestUtils.VCR? _vcr;

Expand All @@ -32,38 +32,6 @@ public class UnitTest : IDisposable
protected UnitTest(string groupName, TestUtils.ApiKey apiKey = TestUtils.ApiKey.Test) => _vcr = new TestUtils.VCR(groupName, apiKey);
#pragma warning restore CS8618

/// <summary>
/// Called automatically by xUnit after each unit test is run.
/// Executes the CleanupFunction (passes in the _cleanupId) if set.
/// </summary>
/// <exception cref="Exception">Could not execute the declared clean-up function.</exception>
public void Dispose()
{
if (CleanupFunction == null)
{
return;
}

if (_cleanupId == null)
{
return;
}

try
{
CleanupFunction.Invoke(_cleanupId).GetAwaiter().GetResult();
_cleanupId = null;
}
catch
{
#pragma warning disable CA2201
throw new Exception("Could not execute clean-up function.");
#pragma warning restore CA2201
}

GC.SuppressFinalize(this);
}

/// <summary>
/// Set the ID that will be passed into the CleanupFunction after each unit test
/// </summary>
Expand Down

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

18 changes: 0 additions & 18 deletions EasyPost/BetaClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,5 @@ internal BetaClient(ClientConfiguration configuration)
Rate = new Services.Beta.RateService(this);
ReferralCustomer = new Services.Beta.ReferralCustomerService(this);
}

/// <inheritdoc cref="EasyPostClient.Dispose(bool)"/>
protected override void Dispose(bool disposing)
{
if (disposing)
{
// Dispose managed state (managed objects).

// Dispose of the services
Rate.Dispose();
ReferralCustomer.Dispose();
}

// Free native resources (unmanaged objects) and override a finalizer below.

// Dispose of the base client
base.Dispose(disposing);
}
}
}
Loading
Loading