mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-26 11:21:51 +01:00
Add helpers for query params fluent MappingModelBuilder (#1425)
* Add helpers for query params * add example with query params * add fluent helpers for WithHeaders and WithCookies --------- Co-authored-by: Logan Dam <Logan.Dam@rabobank.com> Co-authored-by: Stef Heyenrath <Stef.Heyenrath@gmail.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
namespace WireMock.Admin.Mappings;
|
||||
|
||||
public partial class ArrayMatcherModelBuilder
|
||||
{
|
||||
public ArrayMatcherModelBuilder WithExactMatcher(object pattern, bool rejectOnMatch = false, bool ignoreCase = false)
|
||||
{
|
||||
return WithMatcher("ExactMatcher", pattern, rejectOnMatch, ignoreCase);
|
||||
}
|
||||
|
||||
public ArrayMatcherModelBuilder WithWildcardMatcher(object pattern, bool rejectOnMatch = false, bool ignoreCase = false)
|
||||
{
|
||||
return WithMatcher("WildcardMatcher", pattern, rejectOnMatch, ignoreCase);
|
||||
}
|
||||
|
||||
public ArrayMatcherModelBuilder WithRegexMatcher(object pattern, bool rejectOnMatch = false, bool ignoreCase = false)
|
||||
{
|
||||
return WithMatcher("RegexMatcher", pattern, rejectOnMatch, ignoreCase);
|
||||
}
|
||||
|
||||
public ArrayMatcherModelBuilder WithNotNullOrEmptyMatcher(bool rejectOnMatch = false)
|
||||
{
|
||||
return Add(mb => mb
|
||||
.WithName("NotNullOrEmptyMatcher")
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
);
|
||||
}
|
||||
|
||||
private ArrayMatcherModelBuilder WithMatcher(string name, object pattern, bool rejectOnMatch, bool ignoreCase = false)
|
||||
{
|
||||
return Add(mb => mb
|
||||
.WithName(name)
|
||||
.WithPattern(pattern)
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
.WithIgnoreCase(ignoreCase)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WireMock.Admin.Mappings;
|
||||
|
||||
public partial class IListCookieModelBuilder
|
||||
{
|
||||
public IListCookieModelBuilder WithCookie(string name, Action<IListMatcherModelBuilder> action, bool rejectOnMatch = false)
|
||||
{
|
||||
return Add(cookieBuilder => cookieBuilder
|
||||
.WithName(name)
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
.WithMatchers(matchersBuilder => action(matchersBuilder))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WireMock.Admin.Mappings;
|
||||
|
||||
public partial class IListHeaderModelBuilder
|
||||
{
|
||||
public IListHeaderModelBuilder WithHeader(string name, Action<IListMatcherModelBuilder> action, bool rejectOnMatch = false)
|
||||
{
|
||||
return Add(headerBuilder => headerBuilder
|
||||
.WithName(name)
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
.WithMatchers(matchersBuilder => action(matchersBuilder))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
namespace WireMock.Admin.Mappings;
|
||||
|
||||
public partial class IListMatcherModelBuilder
|
||||
{
|
||||
public IListMatcherModelBuilder WithExactMatcher(object pattern, bool rejectOnMatch = false, bool ignoreCase = false)
|
||||
{
|
||||
return WithMatcher("ExactMatcher", pattern, rejectOnMatch, ignoreCase);
|
||||
}
|
||||
|
||||
public IListMatcherModelBuilder WithWildcardMatcher(object pattern, bool rejectOnMatch = false, bool ignoreCase = false)
|
||||
{
|
||||
return WithMatcher("WildcardMatcher", pattern, rejectOnMatch, ignoreCase);
|
||||
}
|
||||
|
||||
public IListMatcherModelBuilder WithRegexMatcher(object pattern, bool rejectOnMatch = false, bool ignoreCase = false)
|
||||
{
|
||||
return WithMatcher("RegexMatcher", pattern, rejectOnMatch, ignoreCase);
|
||||
}
|
||||
|
||||
public IListMatcherModelBuilder WithNotNullOrEmptyMatcher(bool rejectOnMatch = false)
|
||||
{
|
||||
return Add(mb => mb
|
||||
.WithName("NotNullOrEmptyMatcher")
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
);
|
||||
}
|
||||
|
||||
private IListMatcherModelBuilder WithMatcher(string name, object pattern, bool rejectOnMatch, bool ignoreCase = false)
|
||||
{
|
||||
return Add(mb => mb
|
||||
.WithName(name)
|
||||
.WithPattern(pattern)
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
.WithIgnoreCase(ignoreCase)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System;
|
||||
|
||||
namespace WireMock.Admin.Mappings;
|
||||
|
||||
public partial class IListParamModelBuilder
|
||||
{
|
||||
public IListParamModelBuilder WithParam(string name, Action<ArrayMatcherModelBuilder> action, bool rejectOnMatch = false)
|
||||
{
|
||||
return Add(paramBuilder => paramBuilder
|
||||
.WithName(name)
|
||||
.WithRejectOnMatch(rejectOnMatch)
|
||||
.WithMatchers(matchersBuilder => action(matchersBuilder))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user