diff --git a/csharp/Svix.Tests/ApplicationTests.cs b/csharp/Svix.Tests/ApplicationTests.cs index 915cd5de5..71c8553a5 100644 --- a/csharp/Svix.Tests/ApplicationTests.cs +++ b/csharp/Svix.Tests/ApplicationTests.cs @@ -43,247 +43,5 @@ public void ApplicationCreateAsync_WithoutApplication_ThrowsException() // Assert Assert.ThrowsAsync(() => _svixClient.Application.CreateAsync(null, null, null, default)); } - - [Fact] - public void ApplicationCreate_WithoutOptions_CallsApi_WithoutOptions() - { - // Arrange - var lName = "app_name_08q73yhrngv"; - var lUid = "08273gh45"; - var lRateLimit = 30; - - ApplicationCreateOptions lOptions = null; - var lApplication = new ApplicationIn(lName, lRateLimit, lUid); - - // Act - var lApplicationOut = _svixClient.Application.Create(lApplication, lOptions, null); - - // Assert - _mockApplicationApi.Verify(x => x.CreateApplicationApiV1AppPost(lApplication, It.IsAny(), null)); - } - - [Fact] - public void ApplicationCreateAsync_WithoutOptions_CallsApi_WithoutOptions() - { - // Arrange - var lName = "app_name_08q73yhrngv"; - var lUid = "08273gh45"; - var lRateLimit = 30; - - ApplicationCreateOptions lOptions = null; - var lApplication = new ApplicationIn(lName, lRateLimit, lUid); - - // Act - var lResult = _svixClient.Application.CreateAsync(lApplication, lOptions, null, default); - - // Assert - _mockApplicationApi.Verify(x => x.CreateApplicationApiV1AppPostAsync(lApplication, It.IsAny(), null, default)); - } - - [Fact] - public void ApplicationCreate_WithOptions_CallsApi_WithOptions() - { - // Arrange - var lName = "app_name_08q73yhrngv"; - var lUid = "08273gh45"; - var lRateLimit = 30; - - var lApplication = new ApplicationIn(lName, lRateLimit, lUid); - ApplicationCreateOptions lOptions = new ApplicationCreateOptions - { - GetIfExists = true - }; - - // Act - var lApplicationOut = _svixClient.Application.Create(lApplication, lOptions, null); - - // Assert - _mockApplicationApi.Verify(x => x.CreateApplicationApiV1AppPost(lApplication, true, null)); - } - - [Fact] - public void ApplicationCreateAsync_WithOptions_CallsApi_WithOptions() - { - // Arrange - var lName = "app_name_08q73yhrngv"; - var lUid = "08273gh45"; - var lRateLimit = 30; - - var lApplication = new ApplicationIn(lName, lRateLimit, lUid); - ApplicationCreateOptions lOptions = new ApplicationCreateOptions - { - GetIfExists = true - }; - - // Act - var lApplicationOut = _svixClient.Application.CreateAsync(lApplication, lOptions, null, default); - - // Assert - _mockApplicationApi.Verify(x => x.CreateApplicationApiV1AppPostAsync(lApplication, true, null, default)); - } - - [Fact] - public void ApplicationDelete_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockApplicationApi.Setup(x => x.DeleteApplicationApiV1AppAppIdDeleteWithHttpInfo(It.IsAny(), It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Application.Delete(lApplicationId, lIdempotencyKey); - - // Assert - _mockApplicationApi.Verify(x => x.DeleteApplicationApiV1AppAppIdDeleteWithHttpInfo(lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void ApplicationDeleteAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockApplicationApi.Setup(x => x.DeleteApplicationApiV1AppAppIdDeleteWithHttpInfoAsync(It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Application.DeleteAsync(lApplicationId, lIdempotencyKey, default); - - // Assert - _mockApplicationApi.Verify(x => x.DeleteApplicationApiV1AppAppIdDeleteWithHttpInfoAsync(lApplicationId, lIdempotencyKey, default)); - } - - [Fact] - public void ApplicationGet_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Application.Get(lApplicationId, lIdempotencyKey); - - // Assert - _mockApplicationApi.Verify(x => x.GetApplicationApiV1AppAppIdGet(lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void ApplicationGetAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Application.GetAsync(lApplicationId, lIdempotencyKey, default); - - // Assert - _mockApplicationApi.Verify(x => x.GetApplicationApiV1AppAppIdGetAsync(lApplicationId, lIdempotencyKey, default)); - } - - [Fact] - public void ApplicationList_WithoutOptions_CallsApi_WithoutOptions() - { - // Arrange - ListOptions lOptions = null; - - // Act - var lResult = _svixClient.Application - .List(lOptions); - - // Assert - _mockApplicationApi.Verify(x => x.ListApplicationsApiV1AppGet(null, null, null)); - } - - [Fact] - public void ApplicationListAsync_WithoutOptions_CallsApi_WithoutOptions() - { - // Arrange - ListOptions lOptions = null; - - // Act - var lResult = _svixClient.Application - .ListAsync(lOptions); - - // Assert - _mockApplicationApi.Verify(x => x.ListApplicationsApiV1AppGetAsync(null, null, null, default)); - } - - [Fact] - public void ApplicationList_WithOptions_CallsApi_WithOptions() - { - // Arrange - var lIterator = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - var lLimit = 30; - - var lOptions = new ListOptions - { - Iterator = lIterator, - Limit = lLimit - }; - - // Act - var lResult = _svixClient.Application - .List(lOptions); - - // Assert - _mockApplicationApi.Verify(x => x.ListApplicationsApiV1AppGet(lIterator, lLimit, null)); - } - - [Fact] - public void ApplicationListAsync_WithOptions_CallsApi_WithOptions() - { - // Arrange - var lIterator = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - var lLimit = 30; - - var lOptions = new ListOptions - { - Iterator = lIterator, - Limit = lLimit - }; - - // Act - var lResult = _svixClient.Application - .ListAsync(lOptions); - - // Assert - _mockApplicationApi.Verify(x => x.ListApplicationsApiV1AppGetAsync(lIterator, lLimit, null, default)); - } - - [Fact] - public void ApplicationUpdate_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lApplication = new ApplicationIn("MyApplication"); - - // Act - var lResult = _svixClient.Application.Update(lApplicationId, lApplication, lIdempotencyKey); - - // Assert - _mockApplicationApi.Verify(x => x.UpdateApplicationApiV1AppAppIdPut(lApplicationId, lApplication, lIdempotencyKey)); - } - - [Fact] - public void ApplicationUpdateAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lApplication = new ApplicationIn("MyApplication"); - - // Act - var lResult = _svixClient.Application.UpdateAsync(lApplicationId, lApplication, lIdempotencyKey, default); - - // Assert - _mockApplicationApi.Verify(x => x.UpdateApplicationApiV1AppAppIdPutAsync(lApplicationId, lApplication, lIdempotencyKey, default)); - } } } \ No newline at end of file diff --git a/csharp/Svix.Tests/AuthenticationTests.cs b/csharp/Svix.Tests/AuthenticationTests.cs deleted file mode 100644 index 047f33aef..000000000 --- a/csharp/Svix.Tests/AuthenticationTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.Net; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Client; -using Xunit; - -namespace Svix.Tests -{ - public sealed class AuthenticationTests - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockAuthenticationApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public AuthenticationTests() - { - _mockAuthenticationApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - authenticationApi: _mockAuthenticationApi.Object); - } - - [Fact] - public void AuthenticationGetDashboardAccess_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Authentication.GetDashboardAccess(lApplicationId, lIdempotencyKey); - - // Assert - _mockAuthenticationApi.Verify(x => x.GetDashboardAccessApiV1AuthDashboardAccessAppIdPost(lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void AuthenticationGetDashboardAccessAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Authentication.GetDashboardAccessAsync(lApplicationId, lIdempotencyKey, default); - - // Assert - _mockAuthenticationApi.Verify(x => x.GetDashboardAccessApiV1AuthDashboardAccessAppIdPostAsync(lApplicationId, lIdempotencyKey, default)); - } - - [Fact] - public void AuthenticationLogout_CallsApi_WithParams() - { - // Arrange - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockAuthenticationApi.Setup(x => x.LogoutApiV1AuthLogoutPostWithHttpInfo(It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Authentication.Logout(lIdempotencyKey); - - // Assert - _mockAuthenticationApi.Verify(x => x.LogoutApiV1AuthLogoutPostWithHttpInfo(lIdempotencyKey)); - } - - [Fact] - public void AuthenticationLogoutAsync_CallsApi_WithParams() - { - // Arrange - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockAuthenticationApi.Setup(x => x.LogoutApiV1AuthLogoutPostWithHttpInfoAsync(It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Authentication.LogoutAsync(lIdempotencyKey, default); - - // Assert - _mockAuthenticationApi.Verify(x => x.LogoutApiV1AuthLogoutPostWithHttpInfoAsync(lIdempotencyKey, default)); - } - } -} \ No newline at end of file diff --git a/csharp/Svix.Tests/EndpointTests.cs b/csharp/Svix.Tests/EndpointTests.cs deleted file mode 100644 index 35a154ccf..000000000 --- a/csharp/Svix.Tests/EndpointTests.cs +++ /dev/null @@ -1,464 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Client; -using Svix.Model; -using Svix.Models; -using Xunit; - -namespace Svix.Tests -{ - public sealed class EndpointTests - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockEndpointApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public EndpointTests() - { - _mockEndpointApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - endpointApi: _mockEndpointApi.Object); - } - - [Fact] - public void EndpointCreate_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - string lUrl = "https://myEndpointUrl.com"; - var lEndpoint = new EndpointIn(url: lUrl) - { - Version = 1 - }; - - // Act - var lResult = _svixClient.Endpoint.Create(lApplicationId, lEndpoint, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.CreateEndpointApiV1AppAppIdEndpointPost(lApplicationId, lEndpoint, lIdempotencyKey)); - } - - [Fact] - public void EndpointCreateAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - string lUrl = "https://myEndpointUrl.com"; - var lEndpoint = new EndpointIn(url: lUrl) - { - Version = 1 - }; - - // Act - var lResult = _svixClient.Endpoint.CreateAsync(lApplicationId, lEndpoint, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.CreateEndpointApiV1AppAppIdEndpointPostAsync(lApplicationId, lEndpoint, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointDelete_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockEndpointApi.Setup(x => x.DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteWithHttpInfo(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.Delete(lEndpointId, lApplicationId, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteWithHttpInfo(lApplicationId, lEndpointId, lIdempotencyKey)); - } - - [Fact] - public void EndpointDeleteAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockEndpointApi.Setup(x => x.DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteWithHttpInfoAsync(It.IsAny(), It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.DeleteAsync(lEndpointId, lApplicationId, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.DeleteEndpointApiV1AppAppIdEndpointEndpointIdDeleteWithHttpInfoAsync(lApplicationId, lEndpointId, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointGet_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Endpoint.Get(lEndpointId, lApplicationId, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.GetEndpointApiV1AppAppIdEndpointEndpointIdGet(lApplicationId, lEndpointId, lIdempotencyKey)); - } - - [Fact] - public void EndpointGetAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Endpoint.GetAsync(lEndpointId, lApplicationId, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.GetEndpointApiV1AppAppIdEndpointEndpointIdGetAsync(lApplicationId, lEndpointId, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointGetHeaders_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Endpoint.GetHeaders(lEndpointId, lApplicationId, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGet(lApplicationId, lEndpointId, lIdempotencyKey)); - } - - [Fact] - public void EndpointGetHeadersAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Endpoint.GetHeadersAsync(lEndpointId, lApplicationId, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.GetEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersGetAsync(lApplicationId, lEndpointId, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointGetSecret_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Endpoint.GetSecret(lEndpointId, lApplicationId, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGet(lApplicationId, lEndpointId, lIdempotencyKey)); - } - - [Fact] - public void EndpointGetSecretAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Endpoint.GetSecretAsync(lEndpointId, lApplicationId, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.GetEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretGetAsync(lApplicationId, lEndpointId, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointList_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lIterator = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - var lLimit = 30; - var lOptions = new ListOptions - { - Iterator = lIterator, - Limit = lLimit - }; - - // Act - var lResult = _svixClient.Endpoint.List(lApplicationId, lOptions, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.ListEndpointsApiV1AppAppIdEndpointGet(lApplicationId, lIterator, lLimit, lIdempotencyKey)); - } - - [Fact] - public void EndpointListAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lIterator = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - var lLimit = 30; - var lOptions = new ListOptions - { - Iterator = lIterator, - Limit = lLimit - }; - - // Act - var lResult = _svixClient.Endpoint.ListAsync(lApplicationId, lOptions, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.ListEndpointsApiV1AppAppIdEndpointGetAsync(lApplicationId, lIterator, lLimit, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointPatchHeaders_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lHeaderKey = "MyHeaderKey"; - var lHeaderValue = "MyHeaderValue"; - var lHeaders = new EndpointHeadersPatchIn(new Dictionary - { - { lHeaderKey, lHeaderValue } - }); - - _mockEndpointApi.Setup(x => x.PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchWithHttpInfo(It.IsAny(), It.IsAny(), lHeaders, lIdempotencyKey)) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.PatchHeaders(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchWithHttpInfo(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey)); - } - - [Fact] - public void EndpointPatchHeadersAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lHeaderKey = "MyHeaderKey"; - var lHeaderValue = "MyHeaderValue"; - var lHeaders = new EndpointHeadersPatchIn(new Dictionary - { - { lHeaderKey, lHeaderValue } - }); - - _mockEndpointApi.Setup(x => x.PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchWithHttpInfoAsync(It.IsAny(), It.IsAny(), lHeaders, lIdempotencyKey, default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.PatchHeadersAsync(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.PatchEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPatchWithHttpInfoAsync(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointRecover_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lRecover = new RecoverIn(); - - _mockEndpointApi.Setup(x => x.RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostWithHttpInfo(It.IsAny(), It.IsAny(), lRecover, lIdempotencyKey)) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.Recover(lApplicationId, lEndpointId, lRecover, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostWithHttpInfo(lApplicationId, lEndpointId, lRecover, lIdempotencyKey)); - } - - [Fact] - public void EndpointRecoverAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lRecover = new RecoverIn(); - - _mockEndpointApi.Setup(x => x.RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostWithHttpInfoAsync(It.IsAny(), It.IsAny(), lRecover, lIdempotencyKey, default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.RecoverAsync(lApplicationId, lEndpointId, lRecover, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.RecoverFailedWebhooksApiV1AppAppIdEndpointEndpointIdRecoverPostWithHttpInfoAsync(lApplicationId, lEndpointId, lRecover, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointRotateSecret_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lSecret = new EndpointSecretRotateIn(); - - _mockEndpointApi.Setup(x => x.RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostWithHttpInfo(It.IsAny(), It.IsAny(), lSecret, lIdempotencyKey)) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.RotateSecret(lApplicationId, lEndpointId, lSecret, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostWithHttpInfo(lEndpointId, lApplicationId, lSecret, lIdempotencyKey)); - } - - [Fact] - public void EndpointRotateSecretAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lSecret = new EndpointSecretRotateIn(); - - _mockEndpointApi.Setup(x => x.RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostWithHttpInfoAsync(It.IsAny(), It.IsAny(), lSecret, lIdempotencyKey, default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.RotateSecretAsync(lApplicationId, lEndpointId, lSecret, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.RotateEndpointSecretApiV1AppAppIdEndpointEndpointIdSecretRotatePostWithHttpInfoAsync(lEndpointId, lApplicationId, lSecret, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointUpdate_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - string lUrl = "https://myEndpointUrl.com"; - var lEndpoint = new EndpointUpdate(url: lUrl) - { - Version = 1 - }; - - // Act - var lResult = _svixClient.Endpoint.Update(lApplicationId, lEndpointId, lEndpoint, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.UpdateEndpointApiV1AppAppIdEndpointEndpointIdPut(lEndpointId, lApplicationId, lEndpoint, lIdempotencyKey)); - } - - [Fact] - public void EndpointUpdateAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - string lUrl = "https://myEndpointUrl.com"; - var lEndpoint = new EndpointUpdate(url: lUrl) - { - Version = 1 - }; - - // Act - var lResult = _svixClient.Endpoint.UpdateAsync(lApplicationId, lEndpointId, lEndpoint, lIdempotencyKey, default); - - // Assert - _mockEndpointApi.Verify(x => x.UpdateEndpointApiV1AppAppIdEndpointEndpointIdPutAsync(lEndpointId, lApplicationId, lEndpoint, lIdempotencyKey, default)); - } - - [Fact] - public void EndpointUpdateHeaders_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lHeaderKey = "MyHeaderKey"; - var lHeaderValue = "MyHeaderValue"; - var lHeaders = new EndpointHeadersIn(new Dictionary - { - { lHeaderKey, lHeaderValue } - }); - - _mockEndpointApi.Setup(x => x.UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutWithHttpInfo(It.IsAny(), It.IsAny(), lHeaders, lIdempotencyKey)) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.UpdateHeaders(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutWithHttpInfo(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey)); - } - - [Fact] - public void EndpointUpdateHeadersAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lHeaderKey = "MyHeaderKey"; - var lHeaderValue = "MyHeaderValue"; - var lHeaders = new EndpointHeadersIn(new Dictionary - { - { lHeaderKey, lHeaderValue } - }); - - _mockEndpointApi.Setup(x => x.UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutWithHttpInfoAsync(It.IsAny(), It.IsAny(), lHeaders, lIdempotencyKey, default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Endpoint.UpdateHeadersAsync(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey); - - // Assert - _mockEndpointApi.Verify(x => x.UpdateEndpointHeadersApiV1AppAppIdEndpointEndpointIdHeadersPutWithHttpInfoAsync(lApplicationId, lEndpointId, lHeaders, lIdempotencyKey, default)); - } - } -} \ No newline at end of file diff --git a/csharp/Svix.Tests/EventTypeTests.cs b/csharp/Svix.Tests/EventTypeTests.cs deleted file mode 100644 index e9565301c..000000000 --- a/csharp/Svix.Tests/EventTypeTests.cs +++ /dev/null @@ -1,199 +0,0 @@ -using System; -using System.Net; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Client; -using Svix.Model; -using Svix.Models; -using Xunit; - -namespace Svix.Tests -{ - public sealed class EventTypeTests - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockEventTypeApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public EventTypeTests() - { - _mockEventTypeApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - eventTypeApi: _mockEventTypeApi.Object); - } - - [Fact] - public void EventTypeArchive_CallsApi_WithParams() - { - // Arrange - var lEventType = "user.signup"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockEventTypeApi.Setup(x => x.DeleteEventTypeApiV1EventTypeEventTypeNameDeleteWithHttpInfo(It.IsAny(), It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.EventType.Archive(lEventType, lIdempotencyKey); - - // Assert - _mockEventTypeApi.Verify(x => x.DeleteEventTypeApiV1EventTypeEventTypeNameDeleteWithHttpInfo(lEventType, lIdempotencyKey)); - } - - [Fact] - public void EventTypeArchiveAsync_CallsApi_WithParams() - { - // Arrange - var lEventType = "user.signup"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockEventTypeApi.Setup(x => x.DeleteEventTypeApiV1EventTypeEventTypeNameDeleteWithHttpInfoAsync(It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.EventType.ArchiveAsync(lEventType, lIdempotencyKey, default); - - // Assert - _mockEventTypeApi.Verify(x => x.DeleteEventTypeApiV1EventTypeEventTypeNameDeleteWithHttpInfoAsync(lEventType, lIdempotencyKey, default)); - } - - [Fact] - public void EventTypeCreate_CallsApi_WithParams() - { - // Arrange - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lEventType = new EventTypeIn(name: "user.signup", description: "Invoked when a new user is created"); - - // Act - var lResult = _svixClient.EventType.Create(lEventType, lIdempotencyKey); - - // Assert - _mockEventTypeApi.Verify(x => x.CreateEventTypeApiV1EventTypePost(lEventType, lIdempotencyKey)); - } - - [Fact] - public void EventTypeCreateAsync_CallsApi_WithParams() - { - // Arrange - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lEventType = new EventTypeIn(name: "user.signup", description: "Invoked when a new user is created"); - - // Act - var lResult = _svixClient.EventType.CreateAsync(lEventType, lIdempotencyKey, default); - - // Assert - _mockEventTypeApi.Verify(x => x.CreateEventTypeApiV1EventTypePostAsync(lEventType, lIdempotencyKey, default)); - } - - [Fact] - public void EventTypeGet_CallsApi_WithParams() - { - // Arrange - string lEventType = "user.signup"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.EventType.Get(lEventType, lIdempotencyKey); - - // Assert - _mockEventTypeApi.Verify(x => x.GetEventTypeApiV1EventTypeEventTypeNameGet(lEventType, lIdempotencyKey)); - } - - [Fact] - public void EventTypeGetAsync_CallsApi_WithParams() - { - // Arrange - string lEventType = "user.signup"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.EventType.GetAsync(lEventType, lIdempotencyKey); - - // Assert - _mockEventTypeApi.Verify(x => x.GetEventTypeApiV1EventTypeEventTypeNameGetAsync(lEventType, lIdempotencyKey, default)); - } - - [Fact] - public void EventTypeList_CallsApi_WithParams() - { - // Arrange - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new EventTypeListOptions - { - Iterator = "user.signup", - Limit = 50, - IncludeArchived = true, - WithContent = true - }; - - // Act - var lResult = _svixClient.EventType.List(lOptions, lIdempotencyKey); - - // Assert - _mockEventTypeApi.Verify(x => x.ListEventTypesApiV1EventTypeGet(lOptions.Iterator, lOptions.Limit, lOptions.WithContent, lOptions.IncludeArchived, lIdempotencyKey)); - } - - [Fact] - public void EventTypeListAsync_CallsApi_WithParams() - { - // Arrange - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new EventTypeListOptions - { - Iterator = "user.signup", - Limit = 50, - IncludeArchived = true, - WithContent = true - }; - - // Act - var lResult = _svixClient.EventType.ListAsync(lOptions, lIdempotencyKey, default); - - // Assert - _mockEventTypeApi.Verify(x => x.ListEventTypesApiV1EventTypeGetAsync(lOptions.Iterator, lOptions.Limit, lOptions.WithContent, lOptions.IncludeArchived, lIdempotencyKey, default)); - } - - [Fact] - public void EventTypeUpdate_CallsApi_WithParams() - { - // Arrange - string lEventType = "user.signup"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lUpdate = new EventTypeUpdate(description: "Updated description"); - - // Act - var lResult = _svixClient.EventType.Update(lEventType, lUpdate, lIdempotencyKey); - - // Assert - _mockEventTypeApi.Verify(x => x.UpdateEventTypeApiV1EventTypeEventTypeNamePut(lEventType, lUpdate, lIdempotencyKey)); - } - - [Fact] - public void EventTypeUpdateAsync_CallsApi_WithParams() - { - // Arrange - string lEventType = "user.signup"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lUpdate = new EventTypeUpdate(description: "Updated description"); - - // Act - var lResult = _svixClient.EventType.UpdateAsync(lEventType, lUpdate, lIdempotencyKey, default); - - // Assert - _mockEventTypeApi.Verify(x => x.UpdateEventTypeApiV1EventTypeEventTypeNamePutAsync(lEventType, lUpdate, lIdempotencyKey, default)); - } - } -} \ No newline at end of file diff --git a/csharp/Svix.Tests/HealthTests.cs b/csharp/Svix.Tests/HealthTests.cs deleted file mode 100644 index 75637979f..000000000 --- a/csharp/Svix.Tests/HealthTests.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Net; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Client; -using Xunit; - -namespace Svix.Tests -{ - public sealed class HealthTests : IDisposable - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockHealthApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public HealthTests() - { - _mockHealthApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - healthApi: _mockHealthApi.Object); - } - - public void Dispose() - { - // empty - } - - [Fact] - public void IsHealthy_WhenNotHealthy_ReturnsFalse() - { - // Arrange - _mockHealthApi.Setup(x => x.HealthApiV1HealthGetWithHttpInfo(It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.UnprocessableEntity, null)); - - // Act - var lResult = _svixClient.Health - .IsHealthy(); - - // Assert - Assert.False(lResult); - } - - [Fact] - public void IsHealthy_WhenHealthy_ReturnsTrue() - { - // Arrange - _mockHealthApi.Setup(x => x.HealthApiV1HealthGetWithHttpInfo(It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Health - .IsHealthy(); - - // Assert - Assert.True(lResult); - } - - [Fact] - public async void IsHealthyAsync_WhenNotHealthy_ReturnsFalse() - { - // Arrange - _mockHealthApi.Setup(x => x.HealthApiV1HealthGetWithHttpInfoAsync(It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.UnprocessableEntity, null)); - - // Act - var lResult = await _svixClient.Health - .IsHealthyAsync(); - - // Assert - Assert.False(lResult); - } - - [Fact] - public async void IsHealthyAsync_WhenHealthy_ReturnsTrue() - { - // Arrange - _mockHealthApi.Setup(x => x.HealthApiV1HealthGetWithHttpInfoAsync(It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = await _svixClient.Health - .IsHealthyAsync(); - - // Assert - Assert.True(lResult); - } - } -} \ No newline at end of file diff --git a/csharp/Svix.Tests/IntegrationTests.cs b/csharp/Svix.Tests/IntegrationTests.cs deleted file mode 100644 index 00a8b8d0a..000000000 --- a/csharp/Svix.Tests/IntegrationTests.cs +++ /dev/null @@ -1,277 +0,0 @@ -using System; -using System.Net; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Client; -using Svix.Model; -using Svix.Models; -using Xunit; - -namespace Svix.Tests -{ - public sealed class IntegrationTests - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockIntegrationApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public IntegrationTests() - { - _mockIntegrationApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - integrationApi: _mockIntegrationApi.Object); - } - - [Fact] - public void IntegrationCreate_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lIntegration = new IntegrationIn("MyIntegration"); - - // Act - var lResult = _svixClient.Integration.Create(lApplicationId, lIntegration, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.CreateIntegrationApiV1AppAppIdIntegrationPost(lApplicationId, lIntegration, lIdempotencyKey)); - } - - [Fact] - public void IntegrationCreateAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lIntegration = new IntegrationIn("integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"); - - // Act - var lResult = _svixClient.Integration.CreateAsync(lApplicationId, lIntegration, lIdempotencyKey, default); - - // Assert - _mockIntegrationApi.Verify(x => x.CreateIntegrationApiV1AppAppIdIntegrationPostAsync(lApplicationId, lIntegration, lIdempotencyKey, default)); - } - - [Fact] - public void IntegrationDelete_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockIntegrationApi.Setup(x => x.DeleteIntegrationApiV1AppAppIdIntegrationIntegIdDeleteWithHttpInfo(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Integration.Delete(lIntegration, lApplicationId, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.DeleteIntegrationApiV1AppAppIdIntegrationIntegIdDeleteWithHttpInfo(lApplicationId, lIntegration, lIdempotencyKey)); - } - - [Fact] - public void IntegrationDeleteAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockIntegrationApi.Setup(x => x.DeleteIntegrationApiV1AppAppIdIntegrationIntegIdDeleteWithHttpInfoAsync(It.IsAny(), It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.Integration.DeleteAsync(lIntegration, lApplicationId, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.DeleteIntegrationApiV1AppAppIdIntegrationIntegIdDeleteWithHttpInfoAsync(lApplicationId, lIntegration, lIdempotencyKey, default)); - } - - [Fact] - public void IntegrationGet_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Integration.Get(lIntegration, lApplicationId, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.GetIntegrationApiV1AppAppIdIntegrationIntegIdGet(lApplicationId, lIntegration, lIdempotencyKey)); - } - - [Fact] - public void IntegrationGetAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Integration.GetAsync(lIntegration, lApplicationId, lIdempotencyKey, default); - - // Assert - _mockIntegrationApi.Verify(x => x.GetIntegrationApiV1AppAppIdIntegrationIntegIdGetAsync(lApplicationId, lIntegration, lIdempotencyKey, default)); - } - - [Fact] - public void IntegrationGetKey_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockIntegrationApi.Setup(x => x.GetIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyGet(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new IntegrationKeyOut(Guid.NewGuid().ToString())); - - // Act - var lResult = _svixClient.Integration.GetKey(lIntegration, lApplicationId, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.GetIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyGet(lApplicationId, lIntegration, lIdempotencyKey)); - } - - [Fact] - public void IntegrationGetKeyAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockIntegrationApi.Setup(x => x.GetIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyGetAsync(It.IsAny(), It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new IntegrationKeyOut(Guid.NewGuid().ToString())); - - // Act - var lResult = _svixClient.Integration.GetKeyAsync(lIntegration, lApplicationId, lIdempotencyKey, default); - - // Assert - _mockIntegrationApi.Verify(x => x.GetIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyGetAsync(lApplicationId, lIntegration, lIdempotencyKey, default)); - } - - [Fact] - public void IntegrationList_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new ListOptions - { - Iterator = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Limit = 50 - }; - - // Act - var lResult = _svixClient.Integration.List(lApplicationId, lOptions, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.ListIntegrationsApiV1AppAppIdIntegrationGet(lApplicationId, lOptions.Iterator, lOptions.Limit, lIdempotencyKey)); - } - - [Fact] - public void IntegrationListAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new ListOptions - { - Iterator = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Limit = 50 - }; - - // Act - var lResult = _svixClient.Integration.ListAsync(lApplicationId, lOptions, lIdempotencyKey, default); - - // Assert - _mockIntegrationApi.Verify(x => x.ListIntegrationsApiV1AppAppIdIntegrationGetAsync(lApplicationId, lOptions.Iterator, lOptions.Limit, lIdempotencyKey, default)); - } - - [Fact] - public void IntegrationRotateKey_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockIntegrationApi.Setup(x => x.RotateIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyRotatePost(It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new IntegrationKeyOut(Guid.NewGuid().ToString())); - - // Act - var lResult = _svixClient.Integration.RotateKey(lApplicationId, lIntegration, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.RotateIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyRotatePost(lIntegration, lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void IntegrationRotateKeyAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegration = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockIntegrationApi.Setup(x => x.RotateIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyRotatePostAsync(It.IsAny(), It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new IntegrationKeyOut(Guid.NewGuid().ToString())); - - // Act - var lResult = _svixClient.Integration.RotateKeyAsync(lApplicationId, lIntegration, lIdempotencyKey, default); - - // Assert - _mockIntegrationApi.Verify(x => x.RotateIntegrationKeyApiV1AppAppIdIntegrationIntegIdKeyRotatePostAsync(lIntegration, lApplicationId, lIdempotencyKey, default)); - } - - [Fact] - public void IntegrationUpdate_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegrationId = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lIntegration = new IntegrationUpdate("Updated Name"); - - // Act - var lResult = _svixClient.Integration.Update(lApplicationId, lIntegrationId, lIntegration, lIdempotencyKey); - - // Assert - _mockIntegrationApi.Verify(x => x.UpdateIntegrationApiV1AppAppIdIntegrationIntegIdPut(lIntegrationId, lApplicationId, lIntegration, lIdempotencyKey)); - } - - [Fact] - public void IntegrationUpdateAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIntegrationId = "integ_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lIntegration = new IntegrationUpdate("Updated Name"); - - // Act - var lResult = _svixClient.Integration.UpdateAsync(lApplicationId, lIntegrationId, lIntegration, lIdempotencyKey, default); - - // Assert - _mockIntegrationApi.Verify(x => x.UpdateIntegrationApiV1AppAppIdIntegrationIntegIdPutAsync(lIntegrationId, lApplicationId, lIntegration, lIdempotencyKey, default)); - } - } -} \ No newline at end of file diff --git a/csharp/Svix.Tests/MessageAttemptTests.cs b/csharp/Svix.Tests/MessageAttemptTests.cs deleted file mode 100644 index 0f23b7472..000000000 --- a/csharp/Svix.Tests/MessageAttemptTests.cs +++ /dev/null @@ -1,414 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Client; -using Svix.Model; -using Svix.Models; -using Xunit; - -namespace Svix.Tests -{ - public sealed class MessageAttemptTests - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockMessageAttemptApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public MessageAttemptTests() - { - _mockMessageAttemptApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - messageAttemptApi: _mockMessageAttemptApi.Object); - } - - [Fact] - public void MessageAttempt_GetAttempt_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lAttemptId = "atmpt_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.MessageAttempt.GetAttempt(lApplicationId, lAttemptId, lMessageId, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.GetAttemptApiV1AppAppIdMsgMsgIdAttemptAttemptIdGet(lAttemptId, lMessageId, lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_GetAttemptAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lAttemptId = "atmpt_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.MessageAttempt.GetAttemptAsync(lApplicationId, lAttemptId, lMessageId, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.GetAttemptApiV1AppAppIdMsgMsgIdAttemptAttemptIdGetAsync(lAttemptId, lMessageId, lApplicationId, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ListAttemptedMessages_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new MessageAttemptListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Channel = "1337", - Limit = 50, - Status = 0 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptedMessages(lApplicationId, lEndpointId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptedMessagesApiV1AppAppIdEndpointEndpointIdMsgGet(lEndpointId, lApplicationId, lOptions.Iterator, lOptions.Limit, lOptions.Channel, (Svix.Model.MessageStatus)lOptions.Status, lOptions.Before, lOptions.After, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ListAttemptedMessagesAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new MessageAttemptListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Channel = "1337", - Limit = 50, - Status = 0 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptedMessagesAsync(lApplicationId, lEndpointId, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptedMessagesApiV1AppAppIdEndpointEndpointIdMsgGetAsync(lEndpointId, lApplicationId, lOptions.Iterator, lOptions.Limit, lOptions.Channel, (Svix.Model.MessageStatus)lOptions.Status, lOptions.Before, lOptions.After, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ListAttemptsByEndpoint_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new AttemptsByEndpointListOptions - { - Iterator = "atmpt_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Limit = 50, - Status = 0, - Channel = "1337", - EventTypes = new List() { "user.signup" }, - Code = 200 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsByEndpoint(lApplicationId, lEndpointId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsByEndpointApiV1AppAppIdAttemptEndpointEndpointIdGet(lApplicationId, lEndpointId, lOptions.Iterator, lOptions.Limit, (Svix.Model.MessageStatus)lOptions.Status, (Svix.Model.StatusCodeClass)lOptions.Code, lOptions.EventTypes, lOptions.Channel, lOptions.Before, lOptions.After, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ListAttemptsByEndpointAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new AttemptsByEndpointListOptions - { - Iterator = "atmpt_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Limit = 50, - Status = 0, - Channel = "1337", - EventTypes = new List() { "user.signup" }, - Code = 200 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsByEndpointAsync(lApplicationId, lEndpointId, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsByEndpointApiV1AppAppIdAttemptEndpointEndpointIdGetAsync(lApplicationId, lEndpointId, lOptions.Iterator, lOptions.Limit, (Svix.Model.MessageStatus)lOptions.Status, (Svix.Model.StatusCodeClass)lOptions.Code, lOptions.EventTypes, lOptions.Channel, lOptions.Before, lOptions.After, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ListAttemptsByMessage_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new AttemptsByMessageListOptions() - { - EndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Iterator = "atmpt_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Limit = 50, - Status = 0, - Channel = "1337", - EventTypes = new List() { "user.signup" }, - Code = 200 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsByMessage(lApplicationId, lMessageId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsByMsgApiV1AppAppIdAttemptMsgMsgIdGet(lApplicationId, lMessageId, lOptions.EndpointId, lOptions.Iterator, lOptions.Limit, (Svix.Model.MessageStatus)lOptions.Status, (Svix.Model.StatusCodeClass)lOptions.Code, lOptions.EventTypes, lOptions.Channel, lOptions.Before, lOptions.After, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ListAttemptsByMessageAsync_CallsAPi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new AttemptsByMessageListOptions() - { - EndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Iterator = "atmpt_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Limit = 50, - Status = 0, - Channel = "1337", - EventTypes = new List() { "user.signup" }, - Code = 200 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsByMessageAsync(lApplicationId, lMessageId, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsByMsgApiV1AppAppIdAttemptMsgMsgIdGetAsync(lApplicationId, lMessageId, lOptions.EndpointId, lOptions.Iterator, lOptions.Limit, (Svix.Model.MessageStatus)lOptions.Status, (Svix.Model.StatusCodeClass)lOptions.Code, lOptions.EventTypes, lOptions.Channel, lOptions.Before, lOptions.After, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ListAttemptsForEndpoint_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new AttemptsByEndpointListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Limit = 50, - Status = 0, - Channel = "1337", - EventTypes = new List() { "user.signup" } - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsForEndpoint(lApplicationId, lMessageId, lEndpointId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsForEndpointApiV1AppAppIdMsgMsgIdEndpointEndpointIdAttemptGet(lMessageId, lApplicationId, lEndpointId, lOptions.Iterator, lOptions.Limit, lOptions.EventTypes, lOptions.Channel, (Svix.Model.MessageStatus)lOptions.Status, lOptions.Before, lOptions.After, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ListAttemptsForEndpointAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new AttemptsByEndpointListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Limit = 50, - Status = 0, - Channel = "1337", - EventTypes = new List() { "user.signup" } - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsForEndpointAsync(lApplicationId, lMessageId, lEndpointId, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsForEndpointApiV1AppAppIdMsgMsgIdEndpointEndpointIdAttemptGetAsync(lMessageId, lApplicationId, lEndpointId, lOptions.Iterator, lOptions.Limit, lOptions.EventTypes, lOptions.Channel, (Svix.Model.MessageStatus)lOptions.Status, lOptions.Before, lOptions.After, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ListAttempts_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new MessageAttemptListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - EndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2", - EventTypes = new List() { "user.signup" }, - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Channel = "1337", - Limit = 50, - Status = 0 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttempts(lApplicationId, lMessageId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsApiV1AppAppIdMsgMsgIdAttemptGet(lApplicationId, lMessageId, lOptions.Iterator, lOptions.Limit, lOptions.EndpointId, lOptions.EventTypes, lOptions.Channel, (Svix.Model.MessageStatus)lOptions.Status, lOptions.Before, lOptions.After, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ListAttemptsAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new MessageAttemptListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - EndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2", - EventTypes = new List() { "user.signup" }, - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Channel = "1337", - Limit = 50, - Status = 0 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptsAsync(lApplicationId, lMessageId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptsApiV1AppAppIdMsgMsgIdAttemptGetAsync(lApplicationId, lMessageId, lOptions.Iterator, lOptions.Limit, lOptions.EndpointId, lOptions.EventTypes, lOptions.Channel, (Svix.Model.MessageStatus)lOptions.Status, lOptions.Before, lOptions.After, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ListAttemptedDestinations_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new ListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Limit = 50 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptedDestinations(lApplicationId, lMessageId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptedDestinationsApiV1AppAppIdMsgMsgIdEndpointGet(lMessageId, lApplicationId, lOptions.Iterator, lOptions.Limit, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ListAttemptedDestinationsAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new ListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Limit = 50 - }; - - // Act - var lResult = _svixClient.MessageAttempt.ListAttemptedDestinationsAsync(lApplicationId, lMessageId, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ListAttemptedDestinationsApiV1AppAppIdMsgMsgIdEndpointGetAsync(lMessageId, lApplicationId, lOptions.Iterator, lOptions.Limit, lIdempotencyKey, default)); - } - - [Fact] - public void MessageAttempt_ResendWebhook_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockMessageAttemptApi.Setup(x => x.ResendWebhookApiV1AppAppIdMsgMsgIdEndpointEndpointIdResendPostWithHttpInfo(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.MessageAttempt.ResendWebhook(lApplicationId, lMessageId, lEndpointId, lIdempotencyKey); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ResendWebhookApiV1AppAppIdMsgMsgIdEndpointEndpointIdResendPostWithHttpInfo(lEndpointId, lMessageId, lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void MessageAttempt_ResendWebhookAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lEndpointId = "ep_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - _mockMessageAttemptApi.Setup(x => x.ResendWebhookApiV1AppAppIdMsgMsgIdEndpointEndpointIdResendPostWithHttpInfoAsync(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), default)) - .ReturnsAsync(new ApiResponse(HttpStatusCode.NoContent, null)); - - // Act - var lResult = _svixClient.MessageAttempt.ResendWebhookAsync(lApplicationId, lMessageId, lEndpointId, lIdempotencyKey, default); - - // Assert - _mockMessageAttemptApi.Verify(x => x.ResendWebhookApiV1AppAppIdMsgMsgIdEndpointEndpointIdResendPostWithHttpInfoAsync(lEndpointId, lMessageId, lApplicationId, lIdempotencyKey, default)); - } - } -} \ No newline at end of file diff --git a/csharp/Svix.Tests/MessageTests.cs b/csharp/Svix.Tests/MessageTests.cs deleted file mode 100644 index c5c1932ce..000000000 --- a/csharp/Svix.Tests/MessageTests.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections.Generic; -using Moq; -using Svix.Abstractions; -using Svix.Api; -using Svix.Model; -using Svix.Models; -using Xunit; - -namespace Svix.Tests -{ - public sealed class MessageTests - { - private const string MOCK_TOKEN = ";iuani;ansd;ifgjbnai;sdjfgb"; - - private readonly Mock _mockMessageApi; - - private readonly Mock _mockOptions; - - private readonly SvixClient _svixClient; - - public MessageTests() - { - _mockMessageApi = new Mock(); - _mockOptions = new Mock(); - _svixClient = new SvixClient( - MOCK_TOKEN, - _mockOptions.Object, - messageApi: _mockMessageApi.Object); - } - - [Fact] - public void MessageCreate_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lMessage = new MessageIn(eventType: "user.signup", payload: new { }); - - var lOptions = new MessageCreateOptions - { - WithContent = true - }; - - // Act - var lResult = _svixClient.Message.Create(lApplicationId, lMessage, lOptions, lIdempotencyKey); - - // Assert - _mockMessageApi.Verify(x => x.CreateMessageApiV1AppAppIdMsgPost(lApplicationId, lMessage, lOptions.WithContent, lIdempotencyKey)); - } - - [Fact] - public void MessageCreateAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lMessage = new MessageIn(eventType: "user.signup", payload: new { }); - - var lOptions = new MessageCreateOptions - { - WithContent = true - }; - - // Act - var lResult = _svixClient.Message.CreateAsync(lApplicationId, lMessage, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageApi.Verify(x => x.CreateMessageApiV1AppAppIdMsgPostAsync(lApplicationId, lMessage, lOptions.WithContent, lIdempotencyKey, default)); - } - - [Fact] - public void MessageGet_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Message.Get(lApplicationId, lMessageId, lIdempotencyKey); - - // Assert - _mockMessageApi.Verify(x => x.GetMessageApiV1AppAppIdMsgMsgIdGet(lMessageId, lApplicationId, lIdempotencyKey)); - } - - [Fact] - public void MessageGetAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lMessageId = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - // Act - var lResult = _svixClient.Message.GetAsync(lApplicationId, lMessageId, lIdempotencyKey, default); - - // Assert - _mockMessageApi.Verify(x => x.GetMessageApiV1AppAppIdMsgMsgIdGetAsync(lMessageId, lApplicationId, lIdempotencyKey, default)); - } - - [Fact] - public void MessageList_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new MessageListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Channel = "project_1337", - Limit = 50, - EventTypes = new List { "user.signup" } - }; - - // Act - var lResult = _svixClient.Message.List(lApplicationId, lOptions, lIdempotencyKey); - - // Assert - _mockMessageApi.Verify(x => x.ListMessagesApiV1AppAppIdMsgGet(lApplicationId, lOptions.Iterator, lOptions.Limit, lOptions.EventTypes, lOptions.Channel, lOptions.Before, lOptions.After, lIdempotencyKey)); - } - - [Fact] - public void MessageListAsync_CallsApi_WithParams() - { - // Arrange - string lApplicationId = "app_1srOrx2ZWZBpBUvZwXKQmoEYga2"; - string lIdempotencyKey = Guid.NewGuid().ToString(); - - var lOptions = new MessageListOptions - { - Iterator = "msg_1srOrx2ZWZBpBUvZwXKQmoEYga2", - Before = DateTime.Today, - After = DateTime.Today.Subtract(TimeSpan.FromDays(7)), - Channel = "project_1337", - Limit = 50, - EventTypes = new List { "user.signup" } - }; - - // Act - var lResult = _svixClient.Message.ListAsync(lApplicationId, lOptions, lIdempotencyKey, default); - - // Assert - _mockMessageApi.Verify(x => x.ListMessagesApiV1AppAppIdMsgGetAsync(lApplicationId, lOptions.Iterator, lOptions.Limit, lOptions.EventTypes, lOptions.Channel, lOptions.Before, lOptions.After, lIdempotencyKey, default)); - } - } -} \ No newline at end of file