Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Manage Functions to Match Simplier Model Names #227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 40 additions & 44 deletions Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ public void Setup()
}

#region Projects




[Test]
public async Task GetProjects_Should_Call_GetAsync_Returning_ProjectsResponse()
{
Expand Down Expand Up @@ -154,7 +150,7 @@ public async Task DeleteProject_Should_Call_DeleteAsync()

#region ProjectKeys
[Test]
public async Task GetProjectKeys_Should_Call_GetAsync_Returning_KeysResponse()
public async Task GetKeys_Should_Call_GetAsync_Returning_KeysResponse()
{
//Arrange
var expectedResponse = new AutoFaker<KeysResponse>().Generate();
Expand All @@ -166,7 +162,7 @@ public async Task GetProjectKeys_Should_Call_GetAsync_Returning_KeysResponse()
manageClient.GetAsync<KeysResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys").Returns(expectedResponse);

//Act
var result = await manageClient.GetProjectKeys(_projectId);
var result = await manageClient.GetKeys(_projectId);

//Assert
await manageClient.Received().GetAsync<KeysResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys");
Expand All @@ -179,7 +175,7 @@ public async Task GetProjectKeys_Should_Call_GetAsync_Returning_KeysResponse()
}

[Test]
public async Task GetProjectKey_Should_Call_GetAsync_Returning_KeyResponse()
public async Task GetKey_Should_Call_GetAsync_Returning_KeyResponse()
{
//Arrange
var expectedResponse = new AutoFaker<KeyScopeResponse>().Generate();
Expand All @@ -193,7 +189,7 @@ public async Task GetProjectKey_Should_Call_GetAsync_Returning_KeyResponse()


//Act
var result = await manageClient.GetProjectKey(_projectId, keyId);
var result = await manageClient.GetKey(_projectId, keyId);
await manageClient.Received().GetAsync<KeyScopeResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys/{keyId}");

//Assert
Expand All @@ -206,7 +202,7 @@ public async Task GetProjectKey_Should_Call_GetAsync_Returning_KeyResponse()
}

[Test]
public async Task CreateProjectKey_Should_Call_PostAsync_Returning_KeyResponse_Without_Expiration_TimeToLive_Set()
public async Task CreateKey_Should_Call_PostAsync_Returning_KeyResponse_Without_Expiration_TimeToLive_Set()
{
//Arrange
var expectedResponse = new AutoFaker<KeyResponse>().Generate();
Expand All @@ -223,7 +219,7 @@ public async Task CreateProjectKey_Should_Call_PostAsync_Returning_KeyResponse_W


//Act
var result = await manageClient.CreateProjectKey(_projectId, createKeySchema);
var result = await manageClient.CreateKey(_projectId, createKeySchema);

//Assert
await manageClient.Received().PostAsync<KeyResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys", Arg.Any<StringContent>());
Expand All @@ -237,7 +233,7 @@ public async Task CreateProjectKey_Should_Call_PostAsync_Returning_KeyResponse_W
}

[Test]
public async Task CreateProjectKey_Should_Call_PostAsync_Returning_KeyResponse_With_Expiration_Set()
public async Task CreateKey_Should_Call_PostAsync_Returning_KeyResponse_With_Expiration_Set()
{
//Arrange
var expectedResponse = new AutoFaker<KeyResponse>().Generate();
Expand All @@ -253,7 +249,7 @@ public async Task CreateProjectKey_Should_Call_PostAsync_Returning_KeyResponse_W


//Act
var result = await manageClient.CreateProjectKey(_projectId, createKeySchema);
var result = await manageClient.CreateKey(_projectId, createKeySchema);

//Assert
await manageClient.Received().PostAsync<KeyResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys", Arg.Any<StringContent>());
Expand All @@ -267,7 +263,7 @@ public async Task CreateProjectKey_Should_Call_PostAsync_Returning_KeyResponse_W
}

[Test]
public async Task CreateProjectKey_Should_Return_KeyResponse_Without_TimeToLive_Set()
public async Task CreateKey_Should_Return_KeyResponse_Without_TimeToLive_Set()
{
//Arrange
var expectedResponse = new AutoFaker<KeyResponse>().Generate();
Expand All @@ -281,7 +277,7 @@ public async Task CreateProjectKey_Should_Return_KeyResponse_Without_TimeToLive_
manageClient.PostAsync<KeyResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys", Arg.Any<StringContent>()).Returns(expectedResponse);

//Act
var result = await manageClient.CreateProjectKey(_projectId, createKeySchema);
var result = await manageClient.CreateKey(_projectId, createKeySchema);

//Assert
await manageClient.Received().PostAsync<KeyResponse>($"{UriSegments.PROJECTS}/{_projectId}/keys", Arg.Any<StringContent>());
Expand All @@ -295,20 +291,20 @@ public async Task CreateProjectKey_Should_Return_KeyResponse_Without_TimeToLive_
}

[Test]
public async Task CreateProjectKey_Should_Throw_ArgumentException_When_Both_Expiration_And_TimeToLive_Set()
public async Task CreateKey_Should_Throw_ArgumentException_When_Both_Expiration_And_TimeToLive_Set()
{
//Arrange
var createKeySchema = new AutoFaker<KeySchema>().Generate();

var manageClient = new ManageClient(_apiKey, _options) { _httpClientWrapper = new HttpClientWrapper(new HttpClient()) };

//Act & Assert
await manageClient.Invoking(y => y.CreateProjectKey(UriSegments.PROJECTS, createKeySchema))
await manageClient.Invoking(y => y.CreateKey(UriSegments.PROJECTS, createKeySchema))
.Should().ThrowAsync<ArgumentException>();
}

[Test]
public async Task DeleteProjectKey_Should_Call_DeleteAsync()
public async Task DeleteKey_Should_Call_DeleteAsync()
{
//Arrange
var keyId = new Faker().Random.Guid().ToString();
Expand All @@ -320,7 +316,7 @@ public async Task DeleteProjectKey_Should_Call_DeleteAsync()
manageClient.DeleteAsync($"{UriSegments.PROJECTS}/{_projectId}/keys/{keyId}").Returns(Task.CompletedTask);

// Act
await manageClient.DeleteProjectKey(_projectId, keyId);
await manageClient.DeleteKey(_projectId, keyId);

// Assert
await manageClient.Received().DeleteAsync($"{UriSegments.PROJECTS}/{_projectId}/keys/{keyId}");
Expand All @@ -331,7 +327,7 @@ public async Task DeleteProjectKey_Should_Call_DeleteAsync()
#region ProjectInvites

[Test]
public async Task GetProjectInvites_Should_Call_GetAsync_Returning_InvitesResponse()
public async Task GetInvites_Should_Call_GetAsync_Returning_InvitesResponse()
{
//Arrange
var expectedResponse = new AutoFaker<InvitesResponse>().Generate();
Expand All @@ -343,7 +339,7 @@ public async Task GetProjectInvites_Should_Call_GetAsync_Returning_InvitesRespon
manageClient.GetAsync<InvitesResponse>($"{UriSegments.PROJECTS}/{_projectId}/invites").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectInvites(_projectId);
var result = await manageClient.GetInvites(_projectId);

// Assert
await manageClient.Received().GetAsync<InvitesResponse>($"{UriSegments.PROJECTS}/{_projectId}/invites");
Expand All @@ -356,7 +352,7 @@ public async Task GetProjectInvites_Should_Call_GetAsync_Returning_InvitesRespon
}

[Test]
public async Task SendProjectInvite_Should_Call_PostAsync_Returning_MessageResponse()
public async Task SendInvite_Should_Call_PostAsync_Returning_MessageResponse()
{
//Arrange
var expectedResponse = new AutoFaker<MessageResponse>().Generate();
Expand All @@ -369,7 +365,7 @@ public async Task SendProjectInvite_Should_Call_PostAsync_Returning_MessageRespo
manageClient.PostAsync<MessageResponse>($"{UriSegments.PROJECTS}/{_projectId}/invites", Arg.Any<StringContent>()).Returns(expectedResponse);

// Act
var result = await manageClient.SendProjectInvite(_projectId, inviteSchema);
var result = await manageClient.SendInvite(_projectId, inviteSchema);

// Assert
await manageClient.Received().PostAsync<MessageResponse>($"{UriSegments.PROJECTS}/{_projectId}/invites", Arg.Any<StringContent>());
Expand All @@ -382,7 +378,7 @@ public async Task SendProjectInvite_Should_Call_PostAsync_Returning_MessageRespo
}

[Test]
public async Task DeleteProjectInvite_Should_Call_DeleteAsync()
public async Task DeleteInvite_Should_Call_DeleteAsync()
{
//Arrange
var email = new Faker().Internet.Email();
Expand All @@ -394,7 +390,7 @@ public async Task DeleteProjectInvite_Should_Call_DeleteAsync()
manageClient.DeleteAsync($"{UriSegments.PROJECTS}/{_projectId}/invites/{email}").Returns(Task.CompletedTask);

// Act
await manageClient.DeleteProjectInvite(_projectId, email);
await manageClient.DeleteInvite(_projectId, email);

// Assert
await manageClient.Received().DeleteAsync($"{UriSegments.PROJECTS}/{_projectId}/invites/{email}");
Expand All @@ -404,7 +400,7 @@ public async Task DeleteProjectInvite_Should_Call_DeleteAsync()

#region Members
[Test]
public async Task GetProjectMembers_Should_Call_GetAsync_Returning_MembersResponse()
public async Task GetMembers_Should_Call_GetAsync_Returning_MembersResponse()
{
//Arrange
var expectedResponse = new AutoFaker<MembersResponse>().Generate();
Expand All @@ -416,7 +412,7 @@ public async Task GetProjectMembers_Should_Call_GetAsync_Returning_MembersRespon
manageClient.GetAsync<MembersResponse>($"{UriSegments.PROJECTS}/{_projectId}/members").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectMembers(_projectId);
var result = await manageClient.GetMembers(_projectId);

// Assert
await manageClient.Received().GetAsync<MembersResponse>($"{UriSegments.PROJECTS}/{_projectId}/members");
Expand All @@ -429,7 +425,7 @@ public async Task GetProjectMembers_Should_Call_GetAsync_Returning_MembersRespon
}

[Test]
public async Task GetProjectMemberScopes_Should_Call_GetAsync_Returning_MemberScopesResponse()
public async Task GetMemberScopes_Should_Call_GetAsync_Returning_MemberScopesResponse()
{
//Arrange
var expectedResponse = new AutoFaker<MemberScopesResponse>().Generate();
Expand All @@ -443,7 +439,7 @@ public async Task GetProjectMemberScopes_Should_Call_GetAsync_Returning_MemberSc
manageClient.GetAsync<MemberScopesResponse>($"{UriSegments.PROJECTS}/{_projectId}/members/{memberId}/scopes").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectMemberScopes(_projectId, memberId);
var result = await manageClient.GetMemberScopes(_projectId, memberId);

// Assert
await manageClient.Received().GetAsync<MemberScopesResponse>($"{UriSegments.PROJECTS}/{_projectId}/members/{memberId}/scopes");
Expand All @@ -456,7 +452,7 @@ public async Task GetProjectMemberScopes_Should_Call_GetAsync_Returning_MemberSc
}

[Test]
public async Task UpdateProjectMemberScope_Should_Call_PutAsync_Returning_MessageResponse()
public async Task UpdateMemberScope_Should_Call_PutAsync_Returning_MessageResponse()
{
//Arrange
var expectedResponse = new AutoFaker<MessageResponse>().Generate();
Expand All @@ -470,7 +466,7 @@ public async Task UpdateProjectMemberScope_Should_Call_PutAsync_Returning_Messag
manageClient.PutAsync<MessageResponse>($"{UriSegments.PROJECTS}/{_projectId}/members/{memberId}/scopes", Arg.Any<StringContent>()).Returns(expectedResponse);

// Act
var result = await manageClient.UpdateProjectMemberScope(_projectId, memberId, memberScopeSchema);
var result = await manageClient.UpdateMemberScope(_projectId, memberId, memberScopeSchema);

// Assert
await manageClient.Received().PutAsync<MessageResponse>($"{UriSegments.PROJECTS}/{_projectId}/members/{memberId}/scopes", Arg.Any<StringContent>());
Expand All @@ -483,7 +479,7 @@ public async Task UpdateProjectMemberScope_Should_Call_PutAsync_Returning_Messag
}

[Test]
public async Task RemoveProjectMember_Should_Call_DeleteAsync()
public async Task RemoveMember_Should_Call_DeleteAsync()
{
//Arrange
var memberId = new Faker().Random.Guid().ToString();
Expand All @@ -495,7 +491,7 @@ public async Task RemoveProjectMember_Should_Call_DeleteAsync()
manageClient.DeleteAsync($"{UriSegments.PROJECTS}/{_projectId}/members/{memberId}").Returns(Task.CompletedTask);

// Act
await manageClient.RemoveProjectMember(_projectId, memberId);
await manageClient.RemoveMember(_projectId, memberId);

// Assert
await manageClient.Received().DeleteAsync($"{UriSegments.PROJECTS}/{_projectId}/members/{memberId}");
Expand All @@ -505,7 +501,7 @@ public async Task RemoveProjectMember_Should_Call_DeleteAsync()

#region Usage
[Test]
public async Task GetProjectUsageRequests_Should_Call_GetAsync_Returning_UsageRequestsResponse()
public async Task GetUsageRequests_Should_Call_GetAsync_Returning_UsageRequestsResponse()
{
//Arrange
var expectedResponse = new AutoFaker<UsageRequestsResponse>().Generate();
Expand All @@ -519,7 +515,7 @@ public async Task GetProjectUsageRequests_Should_Call_GetAsync_Returning_UsageRe
manageClient.GetAsync<UsageRequestsResponse>($"{UriSegments.PROJECTS}/{_projectId}/requests?{stringedOptions}").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectUsageRequests(_projectId, UsageRequestsSchema);
var result = await manageClient.GetUsageRequests(_projectId, UsageRequestsSchema);

// Assert
await manageClient.Received().GetAsync<UsageRequestsResponse>($"{UriSegments.PROJECTS}/{_projectId}/requests?{stringedOptions}");
Expand All @@ -533,7 +529,7 @@ public async Task GetProjectUsageRequests_Should_Call_GetAsync_Returning_UsageRe
}

[Test]
public async Task GetProjectsUsageRequest_Should_Call_GetAsync_Returning_UsageRequestResponse()
public async Task GetsUsageRequest_Should_Call_GetAsync_Returning_UsageRequestResponse()
{
//Arrange
var requestId = new Faker().Random.Guid().ToString();
Expand All @@ -546,7 +542,7 @@ public async Task GetProjectsUsageRequest_Should_Call_GetAsync_Returning_UsageRe
manageClient.GetAsync<UsageRequestResponse>($"{UriSegments.PROJECTS}/{_projectId}/requests/{requestId}").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectUsageRequest(_projectId, requestId);
var result = await manageClient.GetUsageRequest(_projectId, requestId);

// Assert
await manageClient.Received().GetAsync<UsageRequestResponse>($"{UriSegments.PROJECTS}/{_projectId}/requests/{requestId}");
Expand All @@ -559,7 +555,7 @@ public async Task GetProjectsUsageRequest_Should_Call_GetAsync_Returning_UsageRe
}

[Test]
public async Task GetProjectsUsageSummary_Should_Call_GetAsync_Returning_UsageSummaryResponse()
public async Task GetsUsageSummary_Should_Call_GetAsync_Returning_UsageSummaryResponse()
{
//Arrange
var expectedResponse = new AutoFaker<UsageSummaryResponse>().Generate();
Expand All @@ -573,7 +569,7 @@ public async Task GetProjectsUsageSummary_Should_Call_GetAsync_Returning_UsageSu
manageClient.GetAsync<UsageSummaryResponse>($"{UriSegments.PROJECTS}/{_projectId}/usage?{stringedOptions}").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectUsageSummary(_projectId, getProjectUsageSummarySchema);
var result = await manageClient.GetUsageSummary(_projectId, getProjectUsageSummarySchema);

// Assert
await manageClient.Received().GetAsync<UsageSummaryResponse>($"{UriSegments.PROJECTS}/{_projectId}/usage?{stringedOptions}");
Expand All @@ -587,7 +583,7 @@ public async Task GetProjectsUsageSummary_Should_Call_GetAsync_Returning_UsageSu
}

[Test]
public async Task GetProjectUsageFields_Should_GetAsync_Returning_UsageSummaryResponse()
public async Task GetUsageFields_Should_GetAsync_Returning_UsageSummaryResponse()
{
//Arrange
var expectedResponse = new AutoFaker<UsageFieldsResponse>().Generate();
Expand All @@ -601,7 +597,7 @@ public async Task GetProjectUsageFields_Should_GetAsync_Returning_UsageSummaryRe
manageClient.GetAsync<UsageFieldsResponse>($"{UriSegments.PROJECTS}/{_projectId}/usage/fields?{stringedOptions}").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectUsageFields(_projectId, getProjectUsageFieldsSchema);
var result = await manageClient.GetUsageFields(_projectId, getProjectUsageFieldsSchema);

// Assert
await manageClient.Received().GetAsync<UsageFieldsResponse>($"{UriSegments.PROJECTS}/{_projectId}/usage/fields?{stringedOptions}");
Expand All @@ -619,7 +615,7 @@ public async Task GetProjectUsageFields_Should_GetAsync_Returning_UsageSummaryRe
#region Balances

[Test]
public async Task GetProjectBalances_Should_Call_GetAsync_Returning_BalancesResponse()
public async Task GetBalances_Should_Call_GetAsync_Returning_BalancesResponse()
{
//Arrange
var expectedResponse = new AutoFaker<BalancesResponse>().Generate();
Expand All @@ -631,7 +627,7 @@ public async Task GetProjectBalances_Should_Call_GetAsync_Returning_BalancesResp
manageClient.GetAsync<BalancesResponse>($"{UriSegments.PROJECTS}/{_projectId}/balances").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectBalances(_projectId);
var result = await manageClient.GetBalances(_projectId);

// Assert
await manageClient.Received().GetAsync<BalancesResponse>($"{UriSegments.PROJECTS}/{_projectId}/balances");
Expand All @@ -644,7 +640,7 @@ public async Task GetProjectBalances_Should_Call_GetAsync_Returning_BalancesResp
}

[Test]
public async Task GetProjectBalance_Should_Call_GetAsync_Returning_BalanceResponse()
public async Task GetBalance_Should_Call_GetAsync_Returning_BalanceResponse()
{
//Arrange
var expectedResponse = new AutoFaker<BalanceResponse>().Generate();
Expand All @@ -656,7 +652,7 @@ public async Task GetProjectBalance_Should_Call_GetAsync_Returning_BalanceRespon
manageClient.GetAsync<BalanceResponse>($"{UriSegments.PROJECTS}/{_projectId}/balances/{balanceId}").Returns(expectedResponse);

// Act
var result = await manageClient.GetProjectBalance(_projectId, balanceId);
var result = await manageClient.GetBalance(_projectId, balanceId);

// Assert
await manageClient.Received().GetAsync<BalanceResponse>($"{UriSegments.PROJECTS}/{_projectId}/balances/{balanceId}");
Expand Down
2 changes: 1 addition & 1 deletion Deepgram/Logger/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ internal static partial class Log
EventId = 0018,
Level = LogLevel.Error,
Message = "Error creating project key both ExpirationDate and TimeToLiveInSeconds are set: `{createProjectKeySchema}`")]
internal static partial void CreateProjectKeyError(this ILogger logger, KeySchema createProjectKeySchema);
internal static partial void CreateKeyError(this ILogger logger, KeySchema createProjectKeySchema);
}
Loading
Loading