From 2d064e1c9d73ac268259154a28d4274cc1b25b76 Mon Sep 17 00:00:00 2001 From: Nate Harris Date: Wed, 9 Aug 2023 10:59:33 -0600 Subject: [PATCH] [fix] Make `Id` property of all EasyPostObject publicly settable (#502) - 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 --- EasyPost.Integration/Basics.cs | 17 +++++++++++++++-- EasyPost.Integration/Synchronous.cs | 10 +++++----- EasyPost/_base/EasyPostObject.cs | 2 +- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/EasyPost.Integration/Basics.cs b/EasyPost.Integration/Basics.cs index 74d969b86..09ebe194f 100644 --- a/EasyPost.Integration/Basics.cs +++ b/EasyPost.Integration/Basics.cs @@ -11,7 +11,7 @@ public class Basics /// If this test can be compiled, then the response objects have public constructors. /// [Fact, Testing.Access, Testing.Compile] - public void TestUserCanLocallyConstructResponseObject() + public void UserCanLocallyConstructResponseObject() { var address = new Address(); var addressCollection = new AddressCollection(); @@ -87,12 +87,25 @@ public void TestUserCanLocallyConstructResponseObject() var webhook = new Webhook(); } + /// + /// Test that an end-user can locally construct an object and set its ID. + /// + [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); + } + /// /// Test that an end-user can locally construct all available hooks. /// If this test can be compiled, then the hooks are publicly accessible. /// [Fact, Testing.Access, Testing.Compile] - public void TestUserCanCreateHooks() + public void UserCanCreateHooks() { // Can set up each hook event handler during construction var hooks = new Hooks() diff --git a/EasyPost.Integration/Synchronous.cs b/EasyPost.Integration/Synchronous.cs index 87af8d4ac..35e6d5397 100644 --- a/EasyPost.Integration/Synchronous.cs +++ b/EasyPost.Integration/Synchronous.cs @@ -15,7 +15,7 @@ public class Synchronous /// Test that an end-user can run asynchronous code asynchronously /// [Fact, Testing.Run] - public async void TestUserCanRunAsyncCodeAsynchronously() + public async void UserCanRunAsyncCodeAsynchronously() { var client = Vcr.SetUpTest("async"); @@ -42,7 +42,7 @@ public async void TestUserCanRunAsyncCodeAsynchronously() /// Test that an end-user can run asynchronous code synchronously via .Result /// [Fact, Testing.Run] - public void TestUserCanRunAsyncCodeSynchronouslyViaResult() + public void UserCanRunAsyncCodeSynchronouslyViaResult() { var client = Vcr.SetUpTest("via_result"); @@ -69,7 +69,7 @@ public void TestUserCanRunAsyncCodeSynchronouslyViaResult() /// Test that an end-user can run asynchronous code synchronously via .GetAwaiter().GetResult() /// [Fact, Testing.Run] - public void TestUserCanRunAsyncCodeSynchronouslyViaGetAwaiter() + public void UserCanRunAsyncCodeSynchronouslyViaGetAwaiter() { var client = Vcr.SetUpTest("via_get_awaiter"); @@ -105,7 +105,7 @@ public class SynchronousMvcController : System.Web.Mvc.Controller /// Test that an end-user can run asynchronous code asynchronously /// [Fact, Testing.Run] - public async Task TestUserCanRunAsyncCodeAsynchronously() + public async Task UserCanRunAsyncCodeAsynchronously() { var client = Vcr.SetUpTest("async"); @@ -135,7 +135,7 @@ public async Task TestUserCanRunAsyncCodeAsynchronously() /// Ref: https://gist.github.com/leonardochaia/98ce57bcee39c18d88682424a6ffe305 /// [Fact, Testing.Run] - public ActionResult TestUserCanRunAsyncCodeSynchronouslyViaTaskFactory() + public ActionResult UserCanRunAsyncCodeSynchronouslyViaTaskFactory() { var client = Vcr.SetUpTest("via_task_factory"); diff --git a/EasyPost/_base/EasyPostObject.cs b/EasyPost/_base/EasyPostObject.cs index 39e0f18fe..2285383a5 100644 --- a/EasyPost/_base/EasyPostObject.cs +++ b/EasyPost/_base/EasyPostObject.cs @@ -24,7 +24,7 @@ public abstract class EasyPostObject : EphemeralEasyPostObject /// The EasyPost ID for this object. /// [JsonProperty("id")] - public string? Id { get; internal set; } + public string? Id { get; set; } /// /// The date and time this object was last updated.