mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 17:10:26 +01:00
Add some more tests
This commit is contained in:
35
test/WireMock.Net.Tests/Matchers/JsonPathMatcherTests.cs
Normal file
35
test/WireMock.Net.Tests/Matchers/JsonPathMatcherTests.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using NFluent;
|
||||
using WireMock.Matchers;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Matchers
|
||||
{
|
||||
public class JsonPathMatcherTests
|
||||
{
|
||||
[Fact]
|
||||
public void JsonPathMatcher_GetName()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new JsonPathMatcher("X");
|
||||
|
||||
// Act
|
||||
string name = matcher.GetName();
|
||||
|
||||
// Assert
|
||||
Check.That(name).Equals("JsonPathMatcher");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPathMatcher_GetPatterns()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new JsonPathMatcher("X");
|
||||
|
||||
// Act
|
||||
string[] patterns = matcher.GetPatterns();
|
||||
|
||||
// Assert
|
||||
Check.That(patterns).ContainsExactly("X");
|
||||
}
|
||||
}
|
||||
}
|
||||
35
test/WireMock.Net.Tests/Matchers/XPathMatcherTests.cs
Normal file
35
test/WireMock.Net.Tests/Matchers/XPathMatcherTests.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using NFluent;
|
||||
using WireMock.Matchers;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Matchers
|
||||
{
|
||||
public class XPathMatcherTests
|
||||
{
|
||||
[Fact]
|
||||
public void XPathMatcher_GetName()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new XPathMatcher("X");
|
||||
|
||||
// Act
|
||||
string name = matcher.GetName();
|
||||
|
||||
// Assert
|
||||
Check.That(name).Equals("XPathMatcher");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void XPathMatcher_GetPatterns()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new XPathMatcher("X");
|
||||
|
||||
// Act
|
||||
string[] patterns = matcher.GetPatterns();
|
||||
|
||||
// Assert
|
||||
Check.That(patterns).ContainsExactly("X");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using NFluent;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Serialization
|
||||
{
|
||||
public class MappingConverterTests
|
||||
{
|
||||
[Fact]
|
||||
public void MappingConverter_ToMappingModel()
|
||||
{
|
||||
// Assign
|
||||
var request = Request.Create();
|
||||
var response = Response.Create();
|
||||
var mapping = new Mapping(Guid.NewGuid(), "", null, request, response, 0, null, null, null);
|
||||
|
||||
// Act
|
||||
var model = MappingConverter.ToMappingModel(mapping);
|
||||
|
||||
// Assert
|
||||
Check.That(model).IsNotNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
77
test/WireMock.Net.Tests/Serialization/MatcherMapperTests.cs
Normal file
77
test/WireMock.Net.Tests/Serialization/MatcherMapperTests.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Moq;
|
||||
using NFluent;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Serialization;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Serialization
|
||||
{
|
||||
public class MatcherMapperTests
|
||||
{
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IMatcher_Null()
|
||||
{
|
||||
// Act
|
||||
var model = MatcherMapper.Map((IMatcher)null);
|
||||
|
||||
// Assert
|
||||
Check.That(model).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IMatchers_Null()
|
||||
{
|
||||
// Act
|
||||
var model = MatcherMapper.Map((IMatcher[])null);
|
||||
|
||||
// Assert
|
||||
Check.That(model).IsNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IMatchers()
|
||||
{
|
||||
// Assign
|
||||
var matcherMock1 = new Mock<IStringMatcher>();
|
||||
var matcherMock2 = new Mock<IStringMatcher>();
|
||||
|
||||
// Act
|
||||
var models = MatcherMapper.Map(new [] { matcherMock1.Object, matcherMock2.Object });
|
||||
|
||||
// Assert
|
||||
Check.That(models).HasSize(2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IStringMatcher()
|
||||
{
|
||||
// Assign
|
||||
var matcherMock = new Mock<IStringMatcher>();
|
||||
matcherMock.Setup(m => m.GetName()).Returns("test");
|
||||
matcherMock.Setup(m => m.GetPatterns()).Returns(new[] { "p1", "p2" });
|
||||
|
||||
// Act
|
||||
var model = MatcherMapper.Map(matcherMock.Object);
|
||||
|
||||
// Assert
|
||||
Check.That(model.IgnoreCase).IsNull();
|
||||
Check.That(model.Name).Equals("test");
|
||||
Check.That(model.Pattern).IsNull();
|
||||
Check.That(model.Patterns).ContainsExactly("p1", "p2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MatcherMapper_Map_IIgnoreCaseMatcher()
|
||||
{
|
||||
// Assign
|
||||
var matcherMock = new Mock<IIgnoreCaseMatcher>();
|
||||
matcherMock.Setup(m => m.IgnoreCase).Returns(true);
|
||||
|
||||
// Act
|
||||
var model = MatcherMapper.Map(matcherMock.Object);
|
||||
|
||||
// Assert
|
||||
Check.That(model.IgnoreCase).Equals(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user