diff --git a/Behaviours/Synergy.Behaviours.Testing/FeatureGenerator.cs b/Behaviours/Synergy.Behaviours.Testing/FeatureGenerator.cs index a29f7f7..0ed4ebf 100644 --- a/Behaviours/Synergy.Behaviours.Testing/FeatureGenerator.cs +++ b/Behaviours/Synergy.Behaviours.Testing/FeatureGenerator.cs @@ -30,12 +30,18 @@ public static void Generate( include, exclude, generateAfter, + // ReSharper disable once ExplicitCallerInfoArgument callerFilePath ); - var destinationFilePath = Path.Combine(Path.GetDirectoryName(callerFilePath), to); + var destinationFilePath = Path.Combine(PathFor(callerFilePath), to); File.WriteAllText(destinationFilePath, code); } + private static String PathFor(string callerFilePath) + { + return Path.GetDirectoryName(callerFilePath) ?? throw new ArgumentException("Improper path: " + callerFilePath, nameof(callerFilePath)); + } + public static string Generate( this TBehaviour featureClass, string from, @@ -54,7 +60,7 @@ public static string Generate( StringBuilder code = new StringBuilder(); string className = featureClass.GetType() .Name; - var gherkinPath = Path.Combine(Path.GetDirectoryName(callerFilePath), from); + var gherkinPath = Path.Combine(PathFor(callerFilePath), from); string[] gherkins = FeatureGenerator.ReadAllLinesFrom(gherkinPath); @@ -65,7 +71,7 @@ public static string Generate( code.AppendLine(); code.AppendLine( $"[GeneratedCode(\"{typeof(FeatureGenerator).Assembly.FullName}\", " + - $"\"{typeof(FeatureGenerator).Assembly.GetName().Version.ToString()}\")]" + $"\"{typeof(FeatureGenerator).Assembly.GetName().Version?.ToString()}\")]" ); code.AppendLine($"public partial class {className}"); code.AppendLine("{"); diff --git a/Behaviours/Synergy.Behaviours.Testing/Sentence.cs b/Behaviours/Synergy.Behaviours.Testing/Sentence.cs index bc36b3c..b4cfb37 100644 --- a/Behaviours/Synergy.Behaviours.Testing/Sentence.cs +++ b/Behaviours/Synergy.Behaviours.Testing/Sentence.cs @@ -2,8 +2,6 @@ namespace Synergy.Behaviours.Testing; -// TODO: Marcin Celej [from: Marcin Celej on: 12-05-2023]: Add Public API verification test to see what is exposed from this library - internal static class Sentence { public static string ToMethod(string sentence) diff --git a/Behaviours/Synergy.Behaviours.Testing/Synergy.Behaviours.Testing.csproj b/Behaviours/Synergy.Behaviours.Testing/Synergy.Behaviours.Testing.csproj index cdfbcac..e18a583 100644 --- a/Behaviours/Synergy.Behaviours.Testing/Synergy.Behaviours.Testing.csproj +++ b/Behaviours/Synergy.Behaviours.Testing/Synergy.Behaviours.Testing.csproj @@ -18,15 +18,17 @@ $(Version) + + true + + + + true + + - - true - - - - true - - + + diff --git a/Behaviours/Synergy.Behaviours.Tests/Architecture/Debt/Todos.Technical.Debt.verified.md b/Behaviours/Synergy.Behaviours.Tests/Architecture/Debt/Todos.Technical.Debt.verified.md new file mode 100644 index 0000000..d5cdcf7 --- /dev/null +++ b/Behaviours/Synergy.Behaviours.Tests/Architecture/Debt/Todos.Technical.Debt.verified.md @@ -0,0 +1,7 @@ +# Technical Debt for Synergy.Contracts + +Total: 2 + +## [FeatureGenerator.cs](../../../Synergy.Behaviours.Testing/FeatureGenerator.cs) +- TODO: Marcin Celej [from: Marcin Celej on: 10-05-2023]: Add include / exclude as functions +- TODO: Marcin Celej [from: Marcin Celej on: 10-05-2023]: Support Scenario Outline along with Examples diff --git a/Behaviours/Synergy.Behaviours.Tests/Todos/Todos.cs b/Behaviours/Synergy.Behaviours.Tests/Architecture/Debt/Todos.cs similarity index 80% rename from Behaviours/Synergy.Behaviours.Tests/Todos/Todos.cs rename to Behaviours/Synergy.Behaviours.Tests/Architecture/Debt/Todos.cs index c8ced92..8758d04 100644 --- a/Behaviours/Synergy.Behaviours.Tests/Todos/Todos.cs +++ b/Behaviours/Synergy.Behaviours.Tests/Architecture/Debt/Todos.cs @@ -1,7 +1,7 @@ using Synergy.Documentation.Code; using Synergy.Documentation.Todos; -namespace Synergy.Behaviours.Tests.Todos; +namespace Synergy.Behaviours.Tests.Architecture.Debt; [UsesVerify] public class Todos @@ -10,7 +10,7 @@ public class Todos public async Task Generate() { var rootFolder = CodeFolder.Current() - .Up(2); + .Up(3); var technicalDebt = TodoExplorer.DebtFor("Synergy.Contracts", rootFolder); await Verifier diff --git a/Behaviours/Synergy.Behaviours.Tests/Architecture/Public/Api.cs b/Behaviours/Synergy.Behaviours.Tests/Architecture/Public/Api.cs new file mode 100644 index 0000000..d1f1f1c --- /dev/null +++ b/Behaviours/Synergy.Behaviours.Tests/Architecture/Public/Api.cs @@ -0,0 +1,23 @@ +using Synergy.Behaviours.Testing; +using Synergy.Documentation.Api; + +namespace Synergy.Behaviours.Tests.Architecture.Public; + +[UsesVerify] +public class Api +{ + [Fact] + public async Task Generate() + { + // ARRANGE + var assembly = typeof(Feature<>).Assembly; + + // ACT + var publicApi = ApiDescription.GenerateFor(assembly); + + // ASSERT + await Verifier.Verify(publicApi, "md") + .UseMethodName("of." + assembly.GetName() + .Name); + } +} \ No newline at end of file diff --git a/Behaviours/Synergy.Behaviours.Tests/Architecture/Public/Api.of.Synergy.Behaviours.Testing.verified.md b/Behaviours/Synergy.Behaviours.Tests/Architecture/Public/Api.of.Synergy.Behaviours.Testing.verified.md new file mode 100644 index 0000000..b3f98fe --- /dev/null +++ b/Behaviours/Synergy.Behaviours.Tests/Architecture/Public/Api.of.Synergy.Behaviours.Testing.verified.md @@ -0,0 +1,45 @@ +# Synergy.Behaviours.Testing + +## Feature (abstract class) : IFeature + - And() : TFeature? + - Background() : TFeature? + - But() : TFeature? + - Given() : TFeature? + - Moreover() : TFeature? + - Then() : TFeature? + - When() : TFeature? + +## FeatureGenerator (abstract class) + - FeatureGenerator.Generate( + feature: TBehaviour?, + from: string, + to: string, + include: String[]? [Nullable, Optional], + exclude: String[]? [Nullable, Optional], + generateAfter: Func? [Nullable, Optional], + callerFilePath: string [CallerFilePath, Optional] + ) : void [Extension] + - FeatureGenerator.Generate( + featureClass: TBehaviour?, + from: string, + include: String[]? [Nullable, Optional], + exclude: String[]? [Nullable, Optional], + generateAfter: Func? [Nullable, Optional], + callerFilePath: string [CallerFilePath, Optional] + ) : string [Extension] + +## IFeature (interface) + +## Scenario (record) : IEquatable + - Method: string { get; } + - Tags: ReadOnlyCollection { get; set; } + - Title: string { get; set; } + - ctor( + Title: string, + Tags: ReadOnlyCollection + ) + - IsTagged( + tag: string, + tags: params String[] [ParamArray] + ) : bool + diff --git a/Behaviours/Synergy.Behaviours.Tests/Synergy.Behaviours.Tests.csproj b/Behaviours/Synergy.Behaviours.Tests/Synergy.Behaviours.Tests.csproj index 889b03b..dc3b8df 100644 --- a/Behaviours/Synergy.Behaviours.Tests/Synergy.Behaviours.Tests.csproj +++ b/Behaviours/Synergy.Behaviours.Tests/Synergy.Behaviours.Tests.csproj @@ -8,6 +8,14 @@ Library + + true + + + + true + + diff --git a/Behaviours/Synergy.Behaviours.Tests/Todos/Todos.Technical.Debt.verified.md b/Behaviours/Synergy.Behaviours.Tests/Todos/Todos.Technical.Debt.verified.md deleted file mode 100644 index de38343..0000000 --- a/Behaviours/Synergy.Behaviours.Tests/Todos/Todos.Technical.Debt.verified.md +++ /dev/null @@ -1,10 +0,0 @@ -# Technical Debt for Synergy.Contracts - -Total: 3 - -## [FeatureGenerator.cs](../../Synergy.Behaviours.Testing/FeatureGenerator.cs) -- TODO: Marcin Celej [from: Marcin Celej on: 10-05-2023]: Add include / exclude as functions -- TODO: Marcin Celej [from: Marcin Celej on: 10-05-2023]: Support Scenario Outline along with Examples - -## [Sentence.cs](../../Synergy.Behaviours.Testing/Sentence.cs) -- TODO: Marcin Celej [from: Marcin Celej on: 12-05-2023]: Add Public API verification test to see what is exposed from this library