mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-25 19:02:24 +01:00
Fix generating source code for Scenario and State (#1347)
* Fix generating source code for Scenario and State * Update src/WireMock.Net.Minimal/Serialization/MappingConverter.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/WireMock.Net.Minimal/Serialization/MappingConverter.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * . --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -161,6 +161,16 @@ internal class MappingConverter(MatcherMapper mapper)
|
||||
// Guid
|
||||
sb.AppendLine($" .WithGuid(\"{mapping.Guid}\")");
|
||||
|
||||
// Scenario + State
|
||||
if (!string.IsNullOrEmpty(mapping.Scenario))
|
||||
{
|
||||
sb.AppendLine($" .InScenario({ToCSharpStringLiteral(mapping.Scenario)})");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mapping.NextState))
|
||||
{
|
||||
sb.AppendLine($" .WhenStateIs({ToCSharpStringLiteral(mapping.NextState)}, {ToCSharpIntLiteral(mapping.TimesInSameState)})");
|
||||
}
|
||||
|
||||
if (mapping.Probability != null)
|
||||
{
|
||||
sb.AppendLine($" .WithProbability({mapping.Probability.Value.ToString(CultureInfoUtils.CultureInfoEnUS)})");
|
||||
|
||||
@@ -134,6 +134,8 @@ internal static class CSharpFormatter
|
||||
};
|
||||
}
|
||||
|
||||
public static string ToCSharpIntLiteral(int? value) => value != null ? string.Format(CultureInfo.InvariantCulture, "{0}", value) : Null;
|
||||
|
||||
public static string ToCSharpBooleanLiteral(bool value) => value ? "true" : "false";
|
||||
|
||||
public static string ToCSharpStringLiteral(string? value)
|
||||
|
||||
Reference in New Issue
Block a user