Skip to content

Commit

Permalink
[fix] Make Id property of all EasyPostObject publicly settable (#502)
Browse files Browse the repository at this point in the history
- Make `Id` property of all EasyPostObject public (could override in future if needed)
- Add integration test to verify users can set Id of an object
- Remove "Test" prefix from integration tests
  • Loading branch information
nwithan8 authored Aug 9, 2023
1 parent 9fe4b6a commit 2d064e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
17 changes: 15 additions & 2 deletions EasyPost.Integration/Basics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Basics
/// If this test can be compiled, then the response objects have public constructors.
/// </summary>
[Fact, Testing.Access, Testing.Compile]
public void TestUserCanLocallyConstructResponseObject()
public void UserCanLocallyConstructResponseObject()
{
var address = new Address();
var addressCollection = new AddressCollection();
Expand Down Expand Up @@ -87,12 +87,25 @@ public void TestUserCanLocallyConstructResponseObject()
var webhook = new Webhook();
}

/// <summary>
/// Test that an end-user can locally construct an object and set its ID.
/// </summary>
[Fact, Testing.Access, Testing.Compile]
public void UserCanSetObjectId()
{
// Construct a local object, setting its ID
var address = new Address { Id = "some_id" };

// Assert that the ID was set
Assert.Equal("some_id", address.Id);
}

/// <summary>
/// Test that an end-user can locally construct all available hooks.
/// If this test can be compiled, then the hooks are publicly accessible.
/// </summary>
[Fact, Testing.Access, Testing.Compile]
public void TestUserCanCreateHooks()
public void UserCanCreateHooks()
{
// Can set up each hook event handler during construction
var hooks = new Hooks()
Expand Down
10 changes: 5 additions & 5 deletions EasyPost.Integration/Synchronous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Synchronous
/// Test that an end-user can run asynchronous code asynchronously
/// </summary>
[Fact, Testing.Run]
public async void TestUserCanRunAsyncCodeAsynchronously()
public async void UserCanRunAsyncCodeAsynchronously()
{
var client = Vcr.SetUpTest("async");

Expand All @@ -42,7 +42,7 @@ public async void TestUserCanRunAsyncCodeAsynchronously()
/// Test that an end-user can run asynchronous code synchronously via .Result
/// </summary>
[Fact, Testing.Run]
public void TestUserCanRunAsyncCodeSynchronouslyViaResult()
public void UserCanRunAsyncCodeSynchronouslyViaResult()
{
var client = Vcr.SetUpTest("via_result");

Expand All @@ -69,7 +69,7 @@ public void TestUserCanRunAsyncCodeSynchronouslyViaResult()
/// Test that an end-user can run asynchronous code synchronously via .GetAwaiter().GetResult()
/// </summary>
[Fact, Testing.Run]
public void TestUserCanRunAsyncCodeSynchronouslyViaGetAwaiter()
public void UserCanRunAsyncCodeSynchronouslyViaGetAwaiter()
{
var client = Vcr.SetUpTest("via_get_awaiter");

Expand Down Expand Up @@ -105,7 +105,7 @@ public class SynchronousMvcController : System.Web.Mvc.Controller
/// Test that an end-user can run asynchronous code asynchronously
/// </summary>
[Fact, Testing.Run]
public async Task<ActionResult> TestUserCanRunAsyncCodeAsynchronously()
public async Task<ActionResult> UserCanRunAsyncCodeAsynchronously()
{
var client = Vcr.SetUpTest("async");

Expand Down Expand Up @@ -135,7 +135,7 @@ public async Task<ActionResult> TestUserCanRunAsyncCodeAsynchronously()
/// Ref: https://gist.github.com/leonardochaia/98ce57bcee39c18d88682424a6ffe305
/// </summary>
[Fact, Testing.Run]
public ActionResult TestUserCanRunAsyncCodeSynchronouslyViaTaskFactory()
public ActionResult UserCanRunAsyncCodeSynchronouslyViaTaskFactory()
{
var client = Vcr.SetUpTest("via_task_factory");

Expand Down
2 changes: 1 addition & 1 deletion EasyPost/_base/EasyPostObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class EasyPostObject : EphemeralEasyPostObject
/// The EasyPost ID for this object.
/// </summary>
[JsonProperty("id")]
public string? Id { get; internal set; }
public string? Id { get; set; }

/// <summary>
/// The date and time this object was last updated.
Expand Down

0 comments on commit 2d064e1

Please sign in to comment.