-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
102 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace TheFlow.Conventions | ||
{ | ||
public class ProcessModelConventions | ||
{ | ||
public ProcessModelNamingConventions Naming { get; } | ||
= new ProcessModelNamingConventions(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace TheFlow.Conventions | ||
{ | ||
public class ProcessModelNamingConventions | ||
{ | ||
public Func<string, string> ActivityName { get; set; } = input => | ||
input.EndsWith("Activity") | ||
? input.Substring(0, input.Length - "Activity".Length) | ||
: input; | ||
|
||
public Func<string, string> DataObjectName { get; set; } = input => | ||
(input.StartsWith("On") || input.StartsWith("on")) && char.IsUpper(input[2]) | ||
? input.Substring(2) | ||
: input; | ||
|
||
public Func<string, string> EventCatcher { get; set; } = input => | ||
(input.StartsWith("On") || input.StartsWith("on")) && char.IsUpper(input[2]) | ||
? input | ||
: $"On{input}"; | ||
|
||
public Func<string, string> EventThrower { get; set; } = input => | ||
input.EndsWith("EventThrower") | ||
? input.Substring(0, input.Length - "EventThrower".Length) | ||
: input; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
test/TheFlow.Tests/Unit/DefaultProcessModelNamingConventionsShould.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using FluentAssertions; | ||
using TheFlow.Conventions; | ||
using Xunit; | ||
|
||
namespace TheFlow.Tests.Unit | ||
{ | ||
public class DefaultProcessModelNamingConventionsShould | ||
{ | ||
[Theory] | ||
[InlineData("OnDataObject", "DataObject")] | ||
[InlineData("onDataObject", "DataObject")] | ||
[InlineData("OneInfo", "OneInfo")] | ||
[InlineData("oneInfo", "oneInfo")] | ||
public void ForDataObjects_NotStartWith_On_(string original, string expected) | ||
{ | ||
new ProcessModelNamingConventions() | ||
.DataObjectName(original).Should().Be(expected); | ||
} | ||
|
||
[Theory] | ||
[InlineData("FooActivity", "Foo")] | ||
[InlineData("Inactivity", "Inactivity")] | ||
public void ForAcitivities_NotHaveTheSuffix_Activity(string original, string expected) | ||
{ | ||
new ProcessModelNamingConventions().ActivityName(original).Should().Be(expected); | ||
} | ||
|
||
[Theory] | ||
[InlineData("FooEventThrower", "Foo")] | ||
[InlineData("TheEvent", "TheEvent")] | ||
public void ForEventThrowers_NotHaveTheSuffix_EventThrower(string original, string expected) | ||
{ | ||
new ProcessModelNamingConventions().EventThrower(original).Should().Be(expected); | ||
} | ||
|
||
[Theory] | ||
[InlineData("OnEvent", "OnEvent")] | ||
[InlineData("onEvent", "onEvent")] | ||
[InlineData("Event", "OnEvent")] | ||
public void ForEventCatchers_ShouldStartWith_On(string original, string expected) | ||
{ | ||
new ProcessModelNamingConventions().EventCatcher(original).Should().Be(expected); | ||
} | ||
} | ||
} |