-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
EnhancementNew feature or requestNew feature or request
Description
This is quite similar to the enhancement @ivan-pavlik and I worked on some time ago to unit test the webhook parser: we created one JSON file for each webhook and also created a resource RESX file pointing at all these JSON files. This allowed us to remove all the hardcoded JSON data from the unit tests and replace them with references to resources such as:
var parsedEvent = ParseWebhookEvent<ContactCenterAssetCreatedEvent>(Resource.contact_center_asset_created_webhook);I intend to be the same for all endpoints. Meaning: create a file containing the JSON data returned by each endpoint, create a resource file pointing to all these new files and finally simplify unit tests like so:
// Example of a unit test that references a CONST with hardcoded JSON
private const string SINGLE_ACCOUNT_JSON = @"{
""id"": 123456789,
""account_name"": ""Test Account"",
""owner_email"": ""owner@example.com"",
""account_type"": ""Pro"",
""seats"": 10,
""subscription_start_time"": ""2021-01-01T00:00:00Z"",
""subscription_end_time"": ""2021-12-31T23:59:59Z"",
""created_at"": ""2020-01-01T00:00:00Z""
}";
var mockHttp = new MockHttpMessageHandler();
mockHttp.Expect(HttpMethod.Post, Utils.GetZoomApiUri("accounts"))
.Respond("application/json", SINGLE_ACCOUNT_JSON);
// New test will look something like this (notice the absence of the CONST)
var mockHttp = new MockHttpMessageHandler();
mockHttp.Expect(HttpMethod.Post, Utils.GetZoomApiUri("accounts"))
.Respond("application/json", EndpointsResource.get_single_account);I will create a new resource for all the "endpoint-related" json files, and I will also rename the current Resource.resx to WebhooksResource.resx.
Metadata
Metadata
Assignees
Labels
EnhancementNew feature or requestNew feature or request