Skip to content

Commit

Permalink
test: fixed test for keep alive to apply to the SendData method
Browse files Browse the repository at this point in the history
  • Loading branch information
jjmaldonis committed Sep 8, 2023
1 parent a1cf136 commit 945ce3b
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Deepgram.Tests/ClientTests/LiveTranscriptionClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ public class LiveTranscriptionClientTests
class LiveTranscriptionClientFake : LiveTranscriptionClient
{
private readonly Action<byte[]> _sendDataCallback;
public LiveTranscriptionClientFake(Action<byte[]> sendDataCallback) : base(new Models.Credentials("fake", "fake"))
public LiveTranscriptionClientFake(Action<byte[]> sendDataCallback) : base(new Models.Credentials("fake", "fake"))
{
_sendDataCallback = sendDataCallback ?? throw new ArgumentNullException(nameof(sendDataCallback));
}

}

public override void SendData(byte[] data)
{
_sendDataCallback(data);
}
}
}

[Fact]
public void Test_OnKeepAliveExecuted_SendDataCalledWithData()
public void Test_SendDataCalledWithData()
{
// Arrange
var keepAliveMessage = JsonConvert.SerializeObject(new { type = "KeepAlive" });
var expected = Encoding.Default.GetBytes(keepAliveMessage);
var expected = Encoding.Default.GetBytes("0000");

var sendDataCalled = false;
byte[] sendDataRecieved = null;
Expand All @@ -38,7 +37,7 @@ public void Test_OnKeepAliveExecuted_SendDataCalledWithData()
});

// Act
client.KeepAlive();
client.SendData(expected);

// Assert
Assert.True(sendDataCalled);
Expand Down

0 comments on commit 945ce3b

Please sign in to comment.