-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Amazon services and enhance testing setup
- Simplified return value in `AmazonApiAuthenticatorService` to only return the access token. - Updated sender details in `AmazonShippingRateProvider` for clarity. - Replaced `labelOptions` with `shippingDetails` in `AmazonShippingShipmentProvider` for consistency. - Enhanced `FedExServiceCollectionExtensions` to include logging and register `IFedexApiAuthenticatorService`. - Streamlined service setup by removing unnecessary logging in various service extension classes. - Updated `EasyKeys.Shipping.FuncTest` project file to include references to Amazon Rates and Shipment projects. - Improved `ServiceProviderInstance` for easier Amazon service configuration in tests. - Adjusted shipment date in `TestShipments` for testing scenarios. - Added unit tests for `AmazonShippingRateProvider` and `AmazonShippingShipmentProvider` to validate functionality.
- Loading branch information
Brandon Moffett
committed
Dec 16, 2024
1 parent
c000fbc
commit c1a295b
Showing
13 changed files
with
140 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken c | |
City = shipment.DestinationAddress.City, | ||
CountryCode = shipment.DestinationAddress.CountryCode, | ||
PostalCode = shipment.DestinationAddress.PostalCode, | ||
Email = "unknown name", | ||
PhoneNumber = "unknown phone number" | ||
}, | ||
ShipFrom = new Abstractions.OpenApis.V2.Shipping.Address() | ||
|
@@ -54,6 +53,7 @@ public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken c | |
City = shipment.OriginAddress.City, | ||
CountryCode = shipment.OriginAddress.CountryCode, | ||
PostalCode = shipment.OriginAddress.PostalCode, | ||
Name = "Easykeys fullfuilment team", | ||
Email = "[email protected]", | ||
CompanyName = "EasyKeys", | ||
PhoneNumber = "unknown phone number" | ||
|
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
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
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 |
---|---|---|
|
@@ -39,9 +39,6 @@ public static IServiceCollection AddRestApiFedExRateProvider( | |
string sectionName = nameof(FedExApiOptions), | ||
Action<FedExApiOptions, IServiceProvider>? configOptions = null) | ||
{ | ||
Check warning on line 41 in src/EasyKeys.Shipping.FedEx.Rates/DependencyInjection/FedExRatesServiceCollectionExtensions.cs
|
||
services.AddLogging(); | ||
|
||
services.AddFedExApiClients(); | ||
|
||
services.AddTransient<IFedExRateProvider, EasyKeys.Shipping.FedEx.Rates.RestApi.Impl.FedexRateProvider>(); | ||
|
||
|
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 |
---|---|---|
|
@@ -39,9 +39,6 @@ public static IServiceCollection AddRestApiFedExShipmentProvider( | |
string sectionName = nameof(FedExApiOptions), | ||
Action<FedExApiOptions, IServiceProvider>? configOptions = null) | ||
{ | ||
Check warning on line 41 in src/EasyKeys.Shipping.FedEx.Shipment/DependencyInjection/FedExShippingServiceCollectionExtensions.cs
|
||
services.AddLogging(); | ||
|
||
services.AddFedExApiClients(); | ||
|
||
services.AddTransient<IFedExShipmentProvider, EasyKeys.Shipping.FedEx.Shipment.RestApi.Impl.FedExShipmentProvider>(); | ||
|
||
|
40 changes: 40 additions & 0 deletions
40
test/EasyKeys.Shipping.FuncTest/Amazon/AmazonRateProviderTests.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using EasyKeys.Shipping.Amazon.Rates; | ||
using EasyKeys.Shipping.Stamps.Shipment; | ||
|
||
using EasyKeysShipping.FuncTest.TestHelpers; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace EasyKeys.Shipping.FuncTest.Amazon; | ||
|
||
public class AmazonShippingRateProviderTests | ||
{ | ||
private readonly IAmazonShippingRateProvider _rateProvider; | ||
private readonly ITestOutputHelper _output; | ||
|
||
public AmazonShippingRateProviderTests(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
_rateProvider = ServiceProviderInstance.GetAmazonServices(output) | ||
.GetRequiredService<IAmazonShippingRateProvider>(); | ||
} | ||
|
||
[Fact] | ||
public async Task Return_Shipment_With_Rates_Successfully() | ||
{ | ||
var shipment = TestShipments.CreateDomesticShipment(); | ||
|
||
var result = await _rateProvider.GetRatesAsync(shipment, CancellationToken.None); | ||
|
||
Assert.NotNull(result); | ||
|
||
Assert.NotNull(result.Rates); | ||
|
||
Assert.Empty(result.InternalErrors); | ||
|
||
foreach (var rate in result.Rates) | ||
{ | ||
_output.WriteLine($"{rate.ServiceName} - {rate.TotalCharges} / {rate.TotalCharges2}"); | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
test/EasyKeys.Shipping.FuncTest/Amazon/AmazonShippingShipmentProviderTests.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using EasyKeys.Shipping.Amazon.Shipment; | ||
using EasyKeys.Shipping.Amazon.Shipment.Models; | ||
using EasyKeys.Shipping.Stamps.Abstractions.Models; | ||
using EasyKeys.Shipping.Stamps.Rates.Models; | ||
|
||
using EasyKeysShipping.FuncTest.TestHelpers; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace EasyKeys.Shipping.FuncTest.Amazon; | ||
|
||
public class AmazonShippingShipmentProviderTests | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
private readonly IAmazonShippingShipmentProvider _shipmentProvider; | ||
|
||
public AmazonShippingShipmentProviderTests(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
_shipmentProvider = ServiceProviderInstance.GetAmazonServices(output).GetRequiredService<IAmazonShippingShipmentProvider>(); | ||
} | ||
|
||
[Fact] | ||
public async Task Process_Domestic_Shipment_Successfully() | ||
{ | ||
var (sender, recipient) = TestShipments.CreateContactInfo(); | ||
|
||
var shipmentDetails = new ShippingDetails(); | ||
|
||
shipmentDetails.Sender = sender; | ||
shipmentDetails.Recipient = recipient; | ||
|
||
var rateOptions = new RateOptions() | ||
{ | ||
Sender = sender, | ||
Recipient = recipient, | ||
ServiceType = StampsServiceType.Priority | ||
}; | ||
|
||
var labels = await _shipmentProvider.CreateSmartShipmentAsync( | ||
TestShipments.CreateDomesticShipment(), | ||
shipmentDetails, | ||
CancellationToken.None); | ||
|
||
Assert.NotNull(labels); | ||
Assert.NotNull(labels.Labels[0].Bytes[0]); | ||
} | ||
|
||
} | ||
Check failure on line 49 in test/EasyKeys.Shipping.FuncTest/Amazon/AmazonShippingShipmentProviderTests.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
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