Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ private static void AppendAdditionalMockExtensions(StringBuilder sb, Class @clas
{
sb.AppendLine();
int nameSuffix = 1;
string name = @class.ClassName.Replace('.', '_');
string name = @class.ClassName.Replace('.', '_').Replace("<", "").Replace(">", "");
while (!usedNames.Add(name))
{
name = $"{@class.ClassName.Replace('.', '_')}__{++nameSuffix}";
name = $"{@class.ClassName.Replace('.', '_').Replace("<", "").Replace(">", "")}__{++nameSuffix}";
}
Comment thread
vbreuss marked this conversation as resolved.
Outdated
Comment thread
vbreuss marked this conversation as resolved.
Outdated

string mockExpression =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private static string ExtractFormDataFromMultipartContent(string rawContent)

if (!string.IsNullOrWhiteSpace(line))
{
sb.AppendLine(line.TrimEnd());
sb.AppendLine(line);
Comment thread
vbreuss marked this conversation as resolved.
}
}

Expand Down
20 changes: 20 additions & 0 deletions Tests/Mockolate.Internal.Tests/WebTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ public async Task HttpContentParameter_MatchesWithNullContent_ShouldReturnFalse(
await That(result).IsFalse();
}

[Fact]
public async Task WhenParameterImplementsIHttpRequestMessagePropertyParameter_ShouldUseThisMatch()
{
ItExtensions.IHttpContentParameter parameter =
Mock.Create<ItExtensions.IHttpContentParameter, IParameter,
IHttpRequestMessagePropertyParameter<HttpContent?>>();
parameter.SetupIParameterMock.Method.Matches(It.IsAny<object?>()).Returns(true);
parameter.SetupIHttpRequestMessagePropertyParameterHttpContentMock.Method
.Matches(It.IsAny<HttpContent?>(), It.IsAny<HttpRequestMessage?>()).Returns(true);

ItExtensions.IStringContentBodyParameter sut = parameter.WithString("foo");

bool result = ((IHttpRequestMessagePropertyParameter<HttpContent?>)sut).Matches(null, null);

await That(result).IsTrue();
await That(parameter.VerifyOnIHttpRequestMessagePropertyParameterHttpContentMock.Invoked
.Matches(It.IsNull<HttpContent?>(), It.IsNull<HttpRequestMessage?>()))
.Once();
}

[Fact]
public async Task WithoutMediaTypeHeader_WhenNoneIsRequired_ShouldReturnTrue()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class WithFormDataTests
[InlineData(false, "y", "234", "z", "345", "z", "567")]
[InlineData(false, "x", "123", "z", "345")]
[InlineData(false, "x", "123", "y", "234")]
[InlineData(false, "x", "123", "y", "234", "z", "345")]
public async Task Exactly_ShouldOnlyMatchWhenAllParametersAreChecked(
bool expectSuccess, params string[] rawValues)
{
Expand Down Expand Up @@ -53,7 +54,7 @@ await That(result.StatusCode)
}

[Theory]
[InlineData("x<>", "1<2> 3")]
[InlineData("x<>", "1<2> 3 ")]
public async Task ShouldEncodeValues(string key, string value)
{
HttpClient httpClient = Mock.Create<HttpClient>();
Expand Down
Loading