Skip to content

Add comprehensive unit tests for API request classes#37

Merged
gonace merged 3 commits intomasterfrom
claude/add-requests-tests-9KgJc
Mar 10, 2026
Merged

Add comprehensive unit tests for API request classes#37
gonace merged 3 commits intomasterfrom
claude/add-requests-tests-9KgJc

Conversation

@gonace
Copy link
Copy Markdown
Owner

@gonace gonace commented Mar 10, 2026

Summary

This PR adds comprehensive unit test coverage for all API request classes in the Cronitor SDK, including tests for monitors, notifications, issues, and various operations like pause/unpause, list, get, create, update, and delete.

Key Changes

  • Request Tests Added: Created 18 new test classes covering:

    • Monitor operations: GetMonitorRequest, ListMonitorRequest, UpdateMonitorRequest, DeleteMonitorRequest, PauseMonitorRequest, UnpauseMonitorRequest
    • Monitor details: ListActivitiesRequest, ListAlertsRequest, ListPingsRequest
    • Notification/Template operations: GetNotificationRequest, ListNotificationRequest, CreateNotificationRequest, UpdateNotificationRequest, DeleteNotificationRequest
    • Issue operations: GetIssueRequest, ListIssueRequest, CreateIssueRequest, UpdateIssueRequest
  • Test Coverage: Each request class is tested for:

    • Correct endpoint configuration
    • Proper HTTP method (GET, POST, PUT, DELETE)
    • Key/parameter storage
    • URI generation with proper path and query parameters
    • Request body serialization (where applicable)
  • Test Data Files: Added JSON fixture files for request body validation:

    • UpdateMonitorRequest.json
    • CreateNotificationRequest.json
    • UpdateNotificationRequest.json
    • CreateIssueRequest.json
    • UpdateIssueRequest.json

Notable Implementation Details

  • Tests use the [JsonData] attribute with fixture files to validate serialized request bodies
  • Conditional compilation (#if NET8_0_OR_GREATER) handles async string reading differences between .NET versions
  • Tests verify both simple cases (without optional parameters) and complex cases (with multiple properties)
  • URI building is tested to ensure proper placeholder substitution (e.g., :key → actual key value)

claude and others added 3 commits March 10, 2026 20:04
Add comprehensive tests for all request classes covering endpoint
configuration, HTTP method, key/parameter assignment, URI building,
query string parameters, and serialized content verification.

Tests added for: DeleteMonitor, GetMonitor, ListMonitor,
ListActivities, ListAlerts, ListPings, UpdateMonitor, PauseMonitor,
UnpauseMonitor, CreateNotification, DeleteNotification,
GetNotification, ListNotification, UpdateNotification, CreateIssue,
GetIssue, ListIssue, and UpdateIssue requests.

https://claude.ai/code/session_01YCX6eYsEce6y9hqANb9F7F
Add missing "created":"0001-01-01T00:00:00" to Issue and Notification
JSON test data files. Unlike Monitor.CreatedAt (protected set, excluded
by IgnoreReadOnlyProperties), Issue.CreatedAt and Template.CreatedAt
have public setters and DateTime is a non-nullable value type, so they
are always serialized.

Remove unused System.Net.Http imports from PauseMonitorRequestTests
and UnpauseMonitorRequestTests.

https://claude.ai/code/session_01YCX6eYsEce6y9hqANb9F7F
@gonace gonace merged commit b42fa17 into master Mar 10, 2026
3 checks passed
@gonace gonace deleted the claude/add-requests-tests-9KgJc branch March 10, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants