mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 14:23:34 +01:00
* Add TIOBE + include SonarAnalyzer.CSharp * . * cp * Copyright © WireMock.Net * more fixes * fix * xpath * if (Matchers == null || !Matchers.Any()) * if (Matchers != null) * ? * . * .
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
#if MIMEKIT
|
|
using System.Collections.Generic;
|
|
using FluentAssertions;
|
|
using WireMock.Matchers;
|
|
using WireMock.Matchers.Request;
|
|
using WireMock.RequestBuilders;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.RequestBuilders;
|
|
|
|
public class RequestBuilderWithMultiPartTests
|
|
{
|
|
[Fact]
|
|
public void RequestBuilder_WithMultiPart_MimePartMatcher()
|
|
{
|
|
// Arrange
|
|
var matcher = new MimePartMatcher(MatchBehaviour.AcceptOnMatch, null, null, null, null);
|
|
|
|
// Act
|
|
var requestBuilder = (Request)Request.Create().WithMultiPart(matcher);
|
|
|
|
// Assert
|
|
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
|
matchers.Should().HaveCount(1);
|
|
((RequestMessageMultiPartMatcher)matchers[0]).Matchers.Should().HaveCount(1).And.ContainItemsAssignableTo<MimePartMatcher>();
|
|
}
|
|
|
|
[Fact]
|
|
public void RequestBuilder_WithMultiPart_MimePartMatchers()
|
|
{
|
|
// Arrange
|
|
var matcher1 = new MimePartMatcher(MatchBehaviour.AcceptOnMatch, null, null, null, null);
|
|
var matcher2 = new MimePartMatcher(MatchBehaviour.AcceptOnMatch, null, null, null, null);
|
|
|
|
// Act
|
|
var requestBuilder = (Request)Request.Create().WithMultiPart(MatchBehaviour.RejectOnMatch, matcher1, matcher2);
|
|
|
|
// Assert
|
|
var matchers = requestBuilder.GetPrivateFieldValue<IList<IRequestMatcher>>("_requestMatchers");
|
|
matchers.Should().HaveCount(1);
|
|
|
|
var x = ((RequestMessageMultiPartMatcher)matchers[0]);
|
|
x.MatchBehaviour.Should().Be(MatchBehaviour.RejectOnMatch);
|
|
x.Matchers.Should().HaveCount(2).And.ContainItemsAssignableTo<MimePartMatcher>();
|
|
}
|
|
}
|
|
#endif |