-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from martincostello/UX-Improvements
UX Improvements
- Loading branch information
Showing
15 changed files
with
86 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Martin Costello, 2019. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace MartinCostello.Testing.AwsLambdaTestServer | ||
{ | ||
/// <summary> | ||
/// A class containing extension methods for the <see cref="LambdaTestResponse"/> class. This class cannot be inherited. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public static class LambdaTestResponseExtensions | ||
{ | ||
/// <summary> | ||
/// Reads the content of the specified response as a string as an asynchronous operation. | ||
/// </summary> | ||
/// <param name="response">The response to read as a string.</param> | ||
/// <returns> | ||
/// A <see cref="Task{TResult}"/> representing the asynchronous operation to | ||
/// read the content of the specified response as a <see langword="string"/>. | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException"> | ||
/// <paramref name="response"/> is <see langword="null"/>. | ||
/// </exception> | ||
public static async Task<string> ReadAsStringAsync(this LambdaTestResponse response) | ||
{ | ||
if (response == null) | ||
{ | ||
throw new ArgumentNullException(nameof(response)); | ||
} | ||
|
||
using var stream = new MemoryStream(response.Content); | ||
using var reader = new StreamReader(stream); | ||
|
||
return await reader.ReadToEndAsync().ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/AwsLambdaTestServer.Tests/LambdaTestResponseExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) Martin Costello, 2019. All rights reserved. | ||
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace MartinCostello.Testing.AwsLambdaTestServer | ||
{ | ||
public static class LambdaTestResponseExtensionsTests | ||
{ | ||
[Fact] | ||
public static async Task EnqueueAsync_Validates_Parameters() | ||
{ | ||
// Arrange | ||
LambdaTestResponse response = null; | ||
|
||
// Act | ||
await Assert.ThrowsAsync<ArgumentNullException>("response", () => response.ReadAsStringAsync()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters