mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Add TimesInSameState to MappingModel (#1345)
* Add TimesInSameState to MappingModel * fix tests
This commit is contained in:
@@ -165,5 +165,30 @@
|
||||
]
|
||||
},
|
||||
Response: {}
|
||||
},
|
||||
{
|
||||
Guid: 98fae52e-76df-47d9-876f-2ee32e931005,
|
||||
UpdatedAt: 2023-01-14 15:16:17,
|
||||
Scenario: To do list,
|
||||
SetStateTo: TodoList State Started,
|
||||
TimesInSameState: 2,
|
||||
Request: {
|
||||
Path: {
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: /todo/items,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
},
|
||||
Methods: [
|
||||
GET
|
||||
]
|
||||
},
|
||||
Response: {
|
||||
BodyDestination: SameAsSource,
|
||||
Body: Buy milk
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -66,3 +66,13 @@ builder
|
||||
.RespondWith(Response.Create()
|
||||
);
|
||||
|
||||
builder
|
||||
.Given(Request.Create()
|
||||
.UsingMethod("GET")
|
||||
.WithPath(new WildcardMatcher(WireMock.Matchers.MatchBehaviour.AcceptOnMatch, "/todo/items", false, WireMock.Matchers.MatchOperator.Or))
|
||||
)
|
||||
.WithGuid("98fae52e-76df-47d9-876f-2ee32e931005")
|
||||
.RespondWith(Response.Create()
|
||||
.WithBody("Buy milk")
|
||||
);
|
||||
|
||||
|
||||
@@ -66,3 +66,13 @@ server
|
||||
.RespondWith(Response.Create()
|
||||
);
|
||||
|
||||
server
|
||||
.Given(Request.Create()
|
||||
.UsingMethod("GET")
|
||||
.WithPath(new WildcardMatcher(WireMock.Matchers.MatchBehaviour.AcceptOnMatch, "/todo/items", false, WireMock.Matchers.MatchOperator.Or))
|
||||
)
|
||||
.WithGuid("98fae52e-76df-47d9-876f-2ee32e931005")
|
||||
.RespondWith(Response.Create()
|
||||
.WithBody("Buy milk")
|
||||
);
|
||||
|
||||
|
||||
@@ -161,5 +161,30 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
Guid: 98fae52e-76df-47d9-876f-2ee32e931005,
|
||||
UpdatedAt: 2023-01-14T15:16:17,
|
||||
Scenario: To do list,
|
||||
SetStateTo: TodoList State Started,
|
||||
TimesInSameState: 2,
|
||||
Request: {
|
||||
Path: {
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: /todo/items,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
},
|
||||
Methods: [
|
||||
GET
|
||||
]
|
||||
},
|
||||
Response: {
|
||||
BodyDestination: SameAsSource,
|
||||
Body: Buy milk
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -34,6 +34,7 @@ public class MappingBuilderTests
|
||||
private static readonly DateTime UtcNow = new(2023, 1, 14, 15, 16, 17);
|
||||
|
||||
private readonly Mock<IFileSystemHandler> _fileSystemHandlerMock;
|
||||
private readonly int _numMappings;
|
||||
|
||||
private readonly MappingBuilder _sut;
|
||||
|
||||
@@ -104,11 +105,20 @@ public class MappingBuilderTests
|
||||
).RespondWith(Response.Create());
|
||||
|
||||
_sut.Given(Request.Create()
|
||||
.WithPath("/regex")
|
||||
.WithParam("foo", new RegexMatcher(".*"))
|
||||
.UsingGet()
|
||||
)
|
||||
.RespondWith(Response.Create());
|
||||
.WithPath("/regex")
|
||||
.WithParam("foo", new RegexMatcher(".*"))
|
||||
.UsingGet()
|
||||
).RespondWith(Response.Create());
|
||||
|
||||
_sut.Given(Request.Create()
|
||||
.WithPath("/todo/items")
|
||||
.UsingGet())
|
||||
.InScenario("To do list")
|
||||
.WillSetStateTo("TodoList State Started", 2)
|
||||
.RespondWith(Response.Create()
|
||||
.WithBody("Buy milk"));
|
||||
|
||||
_numMappings = _sut.GetMappings().Length;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -197,9 +207,9 @@ public class MappingBuilderTests
|
||||
_sut.SaveMappingsToFolder(null);
|
||||
|
||||
// Verify
|
||||
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Exactly(5));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(mappingFolder), Times.Exactly(5));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(5));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Exactly(_numMappings));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(mappingFolder), Times.Exactly(_numMappings));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(_numMappings));
|
||||
_fileSystemHandlerMock.VerifyNoOtherCalls();
|
||||
}
|
||||
|
||||
@@ -215,8 +225,8 @@ public class MappingBuilderTests
|
||||
|
||||
// Verify
|
||||
_fileSystemHandlerMock.Verify(fs => fs.GetMappingFolder(), Times.Never);
|
||||
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(path), Times.Exactly(5));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(5));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.FolderExists(path), Times.Exactly(_numMappings));
|
||||
_fileSystemHandlerMock.Verify(fs => fs.WriteMappingFile(It.IsAny<string>(), It.IsAny<string>()), Times.Exactly(_numMappings));
|
||||
_fileSystemHandlerMock.VerifyNoOtherCalls();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user