Skip to content

Commit

Permalink
- Address various warnings in IDE (#467)
Browse files Browse the repository at this point in the history
- Remove unused imports, test utilities
  • Loading branch information
nwithan8 committed May 11, 2023
1 parent 27216fc commit f0bd76b
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 55 deletions.
3 changes: 0 additions & 3 deletions EasyPost.Tests/ClientTest.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using EasyPost.Http;
using EasyPost.Models.API;
using EasyPost.Tests._Utilities;
using EasyPost.Tests._Utilities.Attributes;
using Xunit;
Expand Down
34 changes: 17 additions & 17 deletions EasyPost.Tests/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ internal static ParameterSets.Batch.Create Create(Dictionary<string, object>? fi
shipments = new List<ParameterSets.IShipmentParameter>();
foreach (Dictionary<string, object> shipmentFixture in shipmentsFixture)
{
shipments.Add(Fixtures.Parameters.Shipments.Create(shipmentFixture));
shipments.Add(Shipments.Create(shipmentFixture));
}
}

Expand Down Expand Up @@ -246,7 +246,7 @@ internal static ParameterSets.CustomsInfo.Create Create(Dictionary<string, objec
customsItems = new List<ParameterSets.ICustomsItemParameter>();
foreach (Dictionary<string, object> customsItemFixture in customsItemsFixture)
{
customsItems.Add(Fixtures.Parameters.CustomsItems.Create(customsItemFixture));
customsItems.Add(CustomsItems.Create(customsItemFixture));
}
}

Expand Down Expand Up @@ -346,8 +346,8 @@ internal static ParameterSets.Insurance.Create Create(Dictionary<string, object>
{
Amount = fixture.GetOrNullDouble("amount"),
Carrier = fixture.GetOrNull<string>("carrier"),
ToAddress = Fixtures.Parameters.Addresses.Create(toAddressFixture),
FromAddress = Fixtures.Parameters.Addresses.Create(fromAddressFixture),
ToAddress = Addresses.Create(toAddressFixture),
FromAddress = Addresses.Create(fromAddressFixture),
TrackingCode = fixture.GetOrNull<string>("tracking_code"),
Reference = fixture.GetOrNull<string>("reference"),
};
Expand Down Expand Up @@ -396,14 +396,14 @@ internal static ParameterSets.Order.Create Create(Dictionary<string, object>? fi
shipments = new List<ParameterSets.IShipmentParameter>();
foreach (Dictionary<string, object> shipmentFixture in shipmentsFixture)
{
shipments.Add(Fixtures.Parameters.Shipments.Create(shipmentFixture));
shipments.Add(Shipments.Create(shipmentFixture));
}
}

return new ParameterSets.Order.Create
{
ToAddress = Fixtures.Parameters.Addresses.Create(toAddressFixture),
FromAddress = Fixtures.Parameters.Addresses.Create(fromAddressFixture),
ToAddress = Addresses.Create(toAddressFixture),
FromAddress = Addresses.Create(fromAddressFixture),
Reference = fixture.GetOrNull<string>("reference"),
Shipments = shipments,
};
Expand Down Expand Up @@ -437,7 +437,7 @@ internal static ParameterSets.Pickup.Create Create(Dictionary<string, object>? f

return new ParameterSets.Pickup.Create
{
Address = Fixtures.Parameters.Addresses.Create(addressFixture),
Address = Addresses.Create(addressFixture),
MinDatetime = fixture.GetOrNull<string>("min_datetime"),
MaxDatetime = fixture.GetOrNull<string>("max_datetime"),
Instructions = fixture.GetOrNull<string>("instructions"),
Expand Down Expand Up @@ -472,9 +472,9 @@ internal static ParameterSets.Beta.Rate.Retrieve RetrieveBeta(Dictionary<string,

return new ParameterSets.Beta.Rate.Retrieve
{
ToAddress = Fixtures.Parameters.Addresses.Create(toAddressFixture),
FromAddress = Fixtures.Parameters.Addresses.Create(fromAddressFixture),
Parcel = Fixtures.Parameters.Parcels.Create(parcelFixture),
ToAddress = Addresses.Create(toAddressFixture),
FromAddress = Addresses.Create(fromAddressFixture),
Parcel = Parcels.Create(parcelFixture),
};
}
}
Expand Down Expand Up @@ -607,17 +607,17 @@ internal static ParameterSets.Shipment.Create Create(Dictionary<string, object>?
taxIdentifiers = new List<ParameterSets.ITaxIdentifierParameter>();
foreach (Dictionary<string, object> taxIdentifierFixture in taxIdentifiersFixture)
{
taxIdentifiers.Add(Fixtures.Parameters.TaxIdentifiers.Create(taxIdentifierFixture));
taxIdentifiers.Add(TaxIdentifiers.Create(taxIdentifierFixture));
}
}

return new ParameterSets.Shipment.Create
{
ToAddress = Fixtures.Parameters.Addresses.Create(toAddressFixture),
FromAddress = Fixtures.Parameters.Addresses.Create(fromAddressFixture),
Parcel = Fixtures.Parameters.Parcels.Create(parcelFixture),
CustomsInfo = Fixtures.Parameters.CustomsInfo.Create(customsInfoFixture),
Options = Fixtures.Parameters.Options(optionsFixture),
ToAddress = Addresses.Create(toAddressFixture),
FromAddress = Addresses.Create(fromAddressFixture),
Parcel = Parcels.Create(parcelFixture),
CustomsInfo = CustomsInfo.Create(customsInfoFixture),
Options = Options(optionsFixture),
CarbonOffset = fixture.GetOrDefault<bool>("carbon_offset"), // this will always be true or false, never null
CarrierAccountIds = fixture.GetOrNull<List<string>>("carrier_accounts"),
Carrier = fixture.GetOrNull<string>("carrier"),
Expand Down
2 changes: 0 additions & 2 deletions EasyPost.Tests/HttpTests/ClientConfigurationTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Net.Http;
using EasyPost.Http;
using EasyPost.Tests._Utilities.Attributes;
using Xunit;

Expand Down
2 changes: 1 addition & 1 deletion EasyPost.Tests/ServicesTests/Beta/RateServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task TestGetLowestRateStaticFunction()

List<StatelessRate> rates = await Client.Beta.Rate.RetrieveStatelessRates(shipmentData);

StatelessRate lowestStatelessRate = Utilities.Rates.GetLowestStatelessRate(rates);
StatelessRate lowestStatelessRate = Rates.GetLowestStatelessRate(rates);

Assert.Equal("First", lowestStatelessRate.Service);
}
Expand Down
1 change: 0 additions & 1 deletion EasyPost.Tests/ServicesTests/RateServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost.Models.API;
using EasyPost.Tests._Utilities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using EasyPost.Models.API;
using EasyPost.Tests._Utilities;
Expand Down Expand Up @@ -62,26 +61,5 @@ public async Task TestAll()
#endregion

#endregion

private static string ReferralCustomerKey => TestUtils.GetApiKey(TestUtils.ApiKey.Referral);

private sealed class CreditCard
{
internal readonly string Number;

internal readonly int ExpirationMonth;

internal readonly int ExpirationYear;

internal readonly string Cvc;

internal CreditCard(IReadOnlyDictionary<string, object> details)
{
Number = (string)details["number"];
ExpirationMonth = int.Parse((string)details["expiration_month"], NumberStyles.Number, CultureInfo.InvariantCulture);
ExpirationYear = int.Parse((string)details["expiration_year"], NumberStyles.Number, CultureInfo.InvariantCulture);
Cvc = (string)details["cvc"];
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task TestCreateWithIds()
Address toAddress = await Client.Address.Create(toAddressParameters);
Parcel parcel = await Client.Parcel.Create(parcelParameters);

Dictionary<string, object> shipmentData = new Dictionary<string, object>
Dictionary<string, object> shipmentData = new()
{
{ "from_address", new Dictionary<string, object> { { "id", fromAddress.Id } } },
{ "to_address", new Dictionary<string, object> { { "id", toAddress.Id } } },
Expand All @@ -110,8 +110,6 @@ public async Task TestCreateWithIds()

Parameters.Shipment.Create parameters = Fixtures.Parameters.Shipments.Create(shipmentData);

Dictionary<string, object> dictionary = parameters.ToDictionary();

Shipment shipment = await Client.Shipment.Create(parameters);

Assert.IsType<Shipment>(shipment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ public async Task TestUpdate()
Webhook webhook = await Client.Webhook.Create(webhookParameters);
CleanUpAfterTest(webhook.Id);

Parameters.Webhook.Update updateParameters = new()
{
};
Parameters.Webhook.Update updateParameters = new();
// Sending an empty payload will toggle the active status of the webhook silently.
webhook = await Client.Webhook.Update(webhook.Id, updateParameters);

Expand Down
2 changes: 1 addition & 1 deletion EasyPost.Tests/UtilitiesTests/EnumerablesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void TestEach()

List<int> actual = new();

values.Each((index, value) => actual.Add(value + 1));
values.Each((_, value) => actual.Add(value + 1));

Assert.Equal(expected, actual);
}
Expand Down
2 changes: 1 addition & 1 deletion EasyPost.Tests/_Utilities/Assertions/CollectionAsserts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static void Any<T>(IEnumerable<T> collection, Action<T> action)
GuardArgumentNotNull(nameof(collection), collection);
GuardArgumentNotNull(nameof(action), action);

Any(collection, (item, index) => action(item));
Any(collection, (item, _) => action(item));
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion EasyPost.Tests/_Utilities/UnitTest.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost.Http;

namespace EasyPost.Tests._Utilities
{
Expand Down
2 changes: 2 additions & 0 deletions EasyPost/ClientConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using EasyPost._base;
using EasyPost.Utilities.Internal;
Expand Down Expand Up @@ -120,6 +121,7 @@ internal void SetUp()
// ReSharper disable once NonReadonlyMemberInGetHashCode
#pragma warning disable CA1307
/// <inheritdoc cref="EasyPostObject.GetHashCode()"/>
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode", Justification = "ApiBase and Timeout will never change after construction")]
public override int GetHashCode() => ApiKey.GetHashCode() ^ ApiBase.GetHashCode() ^ Timeout.GetHashCode();
#pragma warning restore CA1307

Expand Down
1 change: 1 addition & 0 deletions EasyPost/Parameters/BaseParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private void Add(RequestParameterAttribute requestParameterAttribute, object? va

return dictionary;

// ReSharper disable once RedundantEmptySwitchSection
default:
break;
}
Expand Down

0 comments on commit f0bd76b

Please sign in to comment.