Skip to content

Commit

Permalink
update tests and rerun recording
Browse files Browse the repository at this point in the history
  • Loading branch information
glorialimicrosoft committed Feb 6, 2024
1 parent 2571506 commit 69ad99a
Show file tree
Hide file tree
Showing 40 changed files with 1,379 additions and 1,386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private NotificationMessagesClient(Uri endpoint, HttpPipeline httpPipeline, Comm
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual async Task<Response<Stream>> DownloadMediaAsync(string mediaContentId, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaAsync)}");
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMedia)}");
scope.Start();
_ = mediaContentId ?? throw new ArgumentNullException(nameof(mediaContentId));

Expand Down Expand Up @@ -141,7 +141,7 @@ public virtual Response<Stream> DownloadMedia(string mediaContentId, Cancellatio
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual async Task<Response> DownloadMediaToAsync(string mediaContentId, Stream destinationStream, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaAsync)}");
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaTo)}");
scope.Start();
_ = mediaContentId ?? throw new ArgumentNullException(nameof(mediaContentId));

Expand All @@ -166,7 +166,7 @@ public virtual async Task<Response> DownloadMediaToAsync(string mediaContentId,
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual Response DownloadMediaTo(string mediaContentId, Stream destinationStream, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMedia)}");
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaTo)}");
scope.Start();
_ = mediaContentId ?? throw new ArgumentNullException(nameof(mediaContentId));

Expand All @@ -191,7 +191,7 @@ public virtual Response DownloadMediaTo(string mediaContentId, Stream destinatio
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual async Task<Response> DownloadMediaToAsync(string mediaContentId, string destinationPath, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaAsync)}");
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaTo)}");
scope.Start();
_ = mediaContentId ?? throw new ArgumentNullException(nameof(mediaContentId));

Expand All @@ -218,7 +218,7 @@ public virtual async Task<Response> DownloadMediaToAsync(string mediaContentId,
/// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
public virtual Response DownloadMediaTo(string mediaContentId, string destinationPath, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMedia)}");
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(NotificationMessagesClient)}.{nameof(DownloadMediaTo)}");
scope.Start();
_ = mediaContentId ?? throw new ArgumentNullException(nameof(mediaContentId));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public NotificationMessagesClientLiveTests(bool isAsync) : base(isAsync)
}

public const string ImageUrl = "https://upload.wikimedia.org/wikipedia/commons/3/30/Building92microsoft.jpg";
public const string VideoUrl = "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4";
public const string DocumentUrl = "https://go.microsoft.com/fwlink/?linkid=2131549";
public const string VideoUrl = "https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4";
public const string DocumentUrl = "https://file-examples.com/storage/fe63e96e0365c0e1e99a842/2017/10/file-sample_150kB.pdf";

[Test]
public void Constructor_NullEndpoint_ShouldThrowArgumentNullException()
Expand Down Expand Up @@ -357,7 +357,6 @@ public Task SendSuperLongTextMessage_ShouldSucceed()
}

[Test]
[Ignore("wait until service side changes are in PROD to run tests.")]
public async Task DownloadMedia_ShouldSucceed()
{
// Arrange
Expand All @@ -373,24 +372,34 @@ public async Task DownloadMedia_ShouldSucceed()
}

[Test]
[Ignore("wait until service side changes are in PROD to run tests.")]
public Task DownloadMedia_InvalidMediaContentId_ShouldFail()
public void DownloadMedia_NullOrEmptyMediaContentId_ShouldFail()
{
// Arrange
NotificationMessagesClient notificationMessagesClient = CreateInstrumentedNotificationMessagesClient();

// Act & Assert
Assert.Throws<ArgumentNullException>(async () => await notificationMessagesClient.DownloadMediaAsync(null));
Assert.Throws<ArgumentException>(async () => await notificationMessagesClient.DownloadMediaAsync(string.Empty));
Assert.Throws<ArgumentException>(async () => await notificationMessagesClient.DownloadMediaAsync(""));
Assert.Throws<ArgumentException>(async () => await notificationMessagesClient.DownloadMediaAsync(" "));
Assert.Throws<ArgumentException>(async () => await notificationMessagesClient.DownloadMediaAsync("test"));
Assert.ThrowsAsync<ArgumentNullException>(async () => await notificationMessagesClient.DownloadMediaAsync(null));
Assert.ThrowsAsync<ArgumentException>(async () => await notificationMessagesClient.DownloadMediaAsync(string.Empty));
Assert.ThrowsAsync<ArgumentException>(async () => await notificationMessagesClient.DownloadMediaAsync(""));
RequestFailedException ex = Assert.ThrowsAsync<RequestFailedException>(async () => await notificationMessagesClient.DownloadMediaAsync(" "));
Assert.NotNull(ex);
Assert.AreEqual(ex?.Status, 400);
}

return Task.CompletedTask;
[Test]
public void DownloadMedia_InvalidMediaContentId_ShouldFail()
{
// Arrange
NotificationMessagesClient notificationMessagesClient = CreateInstrumentedNotificationMessagesClient();

// Act & Assert
RequestFailedException ex = Assert.ThrowsAsync<RequestFailedException>(async () => await notificationMessagesClient.DownloadMediaAsync("test"));
Assert.NotNull(ex);
Assert.AreEqual(ex?.Status, 404);
Assert.AreEqual(ex?.ErrorCode, "MediaNotFound");
}

[Test]
[Ignore("wait until service side changes are in PROD to run tests.")]
public async Task DownloadMediaToStream_ShouldSucceed()
{
// Arrange
Expand All @@ -408,7 +417,6 @@ public async Task DownloadMediaToStream_ShouldSucceed()
}

[Test]
[Ignore("wait until service side changes are in PROD to run tests.")]
public async Task DownloadMediaToFilePath_ShouldSucceed()
{
// Arrange
Expand Down
Loading

0 comments on commit 69ad99a

Please sign in to comment.