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

Model, Module, and Class Naming Reduction/Refactor #190

Merged
merged 1 commit into from
Feb 2, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.user
*.userosscache
*.sln.docstates
*.bak

# Build results
[Dd]ebug/
Expand Down
2 changes: 1 addition & 1 deletion Deepgram.Tests/Fakes/ConcreteRestClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Deepgram.Models.Shared.v1;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram.Tests.Fakes;

Expand Down
24 changes: 12 additions & 12 deletions Deepgram.Tests/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
using System.Diagnostics.CodeAnalysis;

[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.LiveClientTests.GetBaseUrl_Should_Return_WSS_Protocol_When_DeepgramClientOptions_BaseAddress_Contains_No_Protocol")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests.CreateCredentials_Should_Return_OnPremCredentialsResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests.GetCredentials_Should_Call_GetAsync_Returning_OnPremCredentialsResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests.ListCredentials_Should_Call_GetAsync_Returning_ListOnPremCredentialsResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFile_With_Bytes_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFile_With_Stream_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Bytes_With_CallBack_Parameter_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Bytes_With_CallBack_Property_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Stream_With_CallBack_Parameter_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Stream_With_CallBack_Property_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeUrl_Should_Call_PostAsync_Returning_SyncPrerecordedResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeUrlCallBack_Should_Call_PostAsync_Returning_SyncPrerecordedResponse_With_CallBack_Parameter~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeUrlCallBack_Should_Call_PostAsync_Returning_SyncPrerecordedResponse_With_CallBack_Property~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests.CreateCredentials_Should_Return_CredentialResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests.GetCredentials_Should_Call_GetAsync_Returning_CredentialResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests.ListCredentials_Should_Call_GetAsync_Returning_CredentialsResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFile_With_Bytes_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFile_With_Stream_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Bytes_With_CallBack_Parameter_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Bytes_With_CallBack_Property_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Stream_With_CallBack_Parameter_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeFileCallBack_With_Stream_With_CallBack_Property_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeUrl_Should_Call_PostAsync_Returning_SyncResponse~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeUrlCallBack_Should_Call_PostAsync_Returning_SyncResponse_With_CallBack_Parameter~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "member", Target = "~M:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests.TranscribeUrlCallBack_Should_Call_PostAsync_Returning_SyncResponse_With_CallBack_Property~System.Threading.Tasks.Task")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "type", Target = "~T:Deepgram.Tests.UnitTests.ClientTests.OnPremClientTests")]
[assembly: SuppressMessage("Spellchecker", "CRRSP08:A misspelled word has been found", Justification = "<Pending>", Scope = "type", Target = "~T:Deepgram.Tests.UnitTests.ClientTests.PrerecordedClientTests")]
28 changes: 14 additions & 14 deletions Deepgram.Tests/UnitTests/ClientTests/AbstractRestClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Deepgram.DeepgramHttpClient;
using Deepgram.Encapsulations;
using Deepgram.Models.Manage.v1;
using Deepgram.Models.PreRecorded.v1;
using Deepgram.Models.Shared.v1;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram.Tests.UnitTests.ClientTests;

Expand All @@ -22,25 +22,25 @@ public void Setup()
public void GetAsync_Should_Throws_HttpRequestException_On_UnsuccessfulResponse()
{
// Arrange
var expectedResponse = new AutoFaker<GetProjectsResponse>().Generate();
var expectedResponse = new AutoFaker<ProjectsResponse>().Generate();
var httpClient = MockHttpClient.CreateHttpClientWithException(new HttpRequestException());

var client = new ConcreteRestClient(_apiKey, _clientOptions) { _httpClientWrapper = new HttpClientWrapper(httpClient) };
// Act & Assert
client.Invoking(y => y.GetAsync<GetProjectsResponse>(UriSegments.PROJECTS))
client.Invoking(y => y.GetAsync<ProjectsResponse>(UriSegments.PROJECTS))
.Should().ThrowAsync<HttpRequestException>();
}

[Test]
public void GetAsync_Should_Throws_Exception_On_UnsuccessfulResponse()
{
// Arrange
var expectedResponse = new AutoFaker<GetProjectsResponse>().Generate();
var expectedResponse = new AutoFaker<ProjectsResponse>().Generate();
var httpClient = MockHttpClient.CreateHttpClientWithException(new Exception());

var client = new ConcreteRestClient(_apiKey, _clientOptions) { _httpClientWrapper = new HttpClientWrapper(httpClient) };
// Act & Assert
client.Invoking(y => y.GetAsync<GetProjectsResponse>(UriSegments.PROJECTS))
client.Invoking(y => y.GetAsync<ProjectsResponse>(UriSegments.PROJECTS))
.Should().ThrowAsync<Exception>();
}

Expand All @@ -49,14 +49,14 @@ public void GetAsync_Should_Throws_Exception_On_UnsuccessfulResponse()
public void PostAsync_Which_Handles_HttpContent_Should_Throw_Exception_On_UnsuccessfulResponse()
{
// Arrange
var response = new AutoFaker<SyncPrerecordedResponse>().Generate();
var response = new AutoFaker<SyncResponse>().Generate();
var httpContent = Substitute.For<HttpContent>();
var httpClient = MockHttpClient.CreateHttpClientWithException(new Exception());

var client = new ConcreteRestClient(_apiKey, _clientOptions) { _httpClientWrapper = new HttpClientWrapper(httpClient) };

// Act & Assert
client.Invoking(y => y.PostAsync<SyncPrerecordedResponse>(UriSegments.PROJECTS, httpContent))
client.Invoking(y => y.PostAsync<SyncResponse>(UriSegments.PROJECTS, httpContent))
.Should().ThrowAsync<Exception>();
}

Expand All @@ -65,7 +65,7 @@ public void PostAsync_Which_Handles_HttpContent_Should_Throw_Exception_On_Unsucc
public void PostAsync_Which_Handles_HttpContent_Should_Throw_HttpRequestException_On_UnsuccessfulResponse()
{
// Arrange
var response = new AutoFaker<SyncPrerecordedResponse>().Generate();
var response = new AutoFaker<SyncResponse>().Generate();
var httpContent = Substitute.For<HttpContent>();
var httpClient = MockHttpClient.CreateHttpClientWithException(new HttpRequestException());
var client = new ConcreteRestClient(_apiKey, _clientOptions)
Expand All @@ -74,7 +74,7 @@ public void PostAsync_Which_Handles_HttpContent_Should_Throw_HttpRequestExceptio
};

// Act & Assert
client.Invoking(y => y.PostAsync<SyncPrerecordedResponse>(UriSegments.PROJECTS, httpContent))
client.Invoking(y => y.PostAsync<SyncResponse>(UriSegments.PROJECTS, httpContent))
.Should().ThrowAsync<HttpRequestException>();
}

Expand All @@ -83,29 +83,29 @@ public void PostAsync_Which_Handles_HttpContent_Should_Throw_HttpRequestExceptio
public void PostAsync_Should_Throw_Exception_On_UnsuccessfulResponse()
{
// Arrange
var response = new AutoFaker<SyncPrerecordedResponse>().Generate();
var response = new AutoFaker<SyncResponse>().Generate();
var httpClient = MockHttpClient.CreateHttpClientWithException(new Exception());

var client = new ConcreteRestClient(_apiKey, _clientOptions) { _httpClientWrapper = new HttpClientWrapper(httpClient) };

// Act & Assert
client.Invoking(y =>
y.PostAsync<SyncPrerecordedResponse>(UriSegments.PROJECTS, new StringContent(string.Empty)))
y.PostAsync<SyncResponse>(UriSegments.PROJECTS, new StringContent(string.Empty)))
.Should().ThrowAsync<Exception>();
}

[Test]
public void PostAsync_Should_Throw_HttpRequestException_On_UnsuccessfulResponse()
{
// Arrange
var response = new AutoFaker<SyncPrerecordedResponse>().Generate();
var response = new AutoFaker<SyncResponse>().Generate();
var httpClient = MockHttpClient.CreateHttpClientWithException(new HttpRequestException());

var client = new ConcreteRestClient(_apiKey, _clientOptions) { _httpClientWrapper = new HttpClientWrapper(httpClient) };

// Act & Assert
client.Invoking(y =>
y.PostAsync<SyncPrerecordedResponse>(UriSegments.PROJECTS, new StringContent(string.Empty)))
y.PostAsync<SyncResponse>(UriSegments.PROJECTS, new StringContent(string.Empty)))
.Should().ThrowAsync<HttpRequestException>();
}

Expand Down
26 changes: 13 additions & 13 deletions Deepgram.Tests/UnitTests/ClientTests/LiveClientTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Net.WebSockets;
using Deepgram.DeepgramEventArgs;
using Deepgram.Models.Live.v1;
using Deepgram.Models.Shared.v1;
using Deepgram.Models.Authenticate.v1;

namespace Deepgram.Tests.UnitTests.ClientTests;
public class LiveClientTests
Expand All @@ -25,17 +25,17 @@ public void Teardown()
{ _liveClient.Dispose(); }

[Test]
public void ProcessDataReceived_Should_Raise_TranscriptReceived_Event_When_Response_Contains_Type_LiveTranscriptionResponse()
public void ProcessDataReceived_Should_Raise_TranscriptReceived_Event_When_Response_Contains_Type_TranscriptionResponse()
{
//Arrange
var liveTranscriptionResponse = new AutoFaker<LiveTranscriptionResponse>().Generate();
var liveTranscriptionResponse = new AutoFaker<TranscriptionResponse>().Generate();
// ensure the right type is set for testing
liveTranscriptionResponse.Type = Enums.LiveType.Results;
var json = JsonSerializer.Serialize(liveTranscriptionResponse);
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(json));
LiveResponseReceivedEventArgs? eventArgs = null;
ResponseReceivedEventArgs? eventArgs = null;

_liveClient.LiveResponseReceived += (sender, args) => eventArgs = args;
_liveClient.EventResponseReceived += (sender, args) => eventArgs = args;


//Act
Expand All @@ -45,22 +45,22 @@ public void ProcessDataReceived_Should_Raise_TranscriptReceived_Event_When_Respo

eventArgs.Should().NotBeNull();
eventArgs!.Response.Transcription.Should().NotBeNull();
eventArgs.Response.Transcription.Should().BeAssignableTo<LiveTranscriptionResponse>();
eventArgs.Response.Transcription.Should().BeAssignableTo<TranscriptionResponse>();
}

[Test]
public void ProcessDataReceived_Should_Raise_MetaDataReceived_Event_When_Response_Contains_Type_LiveMetadataResponse()
public void ProcessDataReceived_Should_Raise_MetaDataReceived_Event_When_Response_Contains_Type_MetadataResponse()
{
//Arrange
var liveMetadataResponse = new AutoFaker<LiveMetadataResponse>().Generate();
var liveMetadataResponse = new AutoFaker<MetadataResponse>().Generate();
// ensure the right type is set for testing
liveMetadataResponse.Type = Enums.LiveType.Metadata;
var json = JsonSerializer.Serialize(liveMetadataResponse);
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(json));

LiveResponseReceivedEventArgs? eventArgs = null;
ResponseReceivedEventArgs? eventArgs = null;

_liveClient.LiveResponseReceived += (sender, args) => eventArgs = args;
_liveClient.EventResponseReceived += (sender, args) => eventArgs = args;

//Act
_liveClient.ProcessDataReceived(_webSocketReceiveResult, memoryStream);
Expand All @@ -70,7 +70,7 @@ public void ProcessDataReceived_Should_Raise_MetaDataReceived_Event_When_Respons
{
eventArgs.Should().NotBeNull();
eventArgs!.Response.MetaData.Should().NotBeNull();
eventArgs.Response.MetaData.Should().BeAssignableTo<LiveMetadataResponse>();
eventArgs.Response.MetaData.Should().BeAssignableTo<MetadataResponse>();
}
}

Expand All @@ -82,9 +82,9 @@ public void ProcessDataReceived_Should_Raise_LiveError_Event_When_Response_Conta
var json = JsonSerializer.Serialize(unknownDataResponse);
var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(json));

LiveResponseReceivedEventArgs? eventArgs = null;
ResponseReceivedEventArgs? eventArgs = null;

_liveClient.LiveResponseReceived += (sender, args) => eventArgs = args;
_liveClient.EventResponseReceived += (sender, args) => eventArgs = args;

//Act
_liveClient.ProcessDataReceived(_webSocketReceiveResult, memoryStream);
Expand Down
Loading
Loading