From 98bc7c73a1ed20d0e4f9d15c674e05f502502c77 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 13 Oct 2021 15:37:01 +0200 Subject: [PATCH 1/5] Add snapshot builder --- src/Snapshooter.NUnit/NUnitSnapshotBuilder.cs | 25 +++ src/Snapshooter.NUnit/SnapshotExtension.cs | 27 ++- src/Snapshooter.Xunit/SnapshotExtension.cs | 28 ++- src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs | 24 +++ src/Snapshooter/ISnapshotBuilder.cs | 33 ++++ src/Snapshooter/SnapshotBuilder.cs | 82 +++++++++ src/Snapshooter/SnapshotBuilderExtensions.cs | 159 ++++++++++++++++++ src/Snapshooter/SnapshotFullNameResolver.cs | 43 +++-- 8 files changed, 381 insertions(+), 40 deletions(-) create mode 100644 src/Snapshooter.NUnit/NUnitSnapshotBuilder.cs create mode 100644 src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs create mode 100644 src/Snapshooter/ISnapshotBuilder.cs create mode 100644 src/Snapshooter/SnapshotBuilder.cs create mode 100644 src/Snapshooter/SnapshotBuilderExtensions.cs diff --git a/src/Snapshooter.NUnit/NUnitSnapshotBuilder.cs b/src/Snapshooter.NUnit/NUnitSnapshotBuilder.cs new file mode 100644 index 0000000..b9e106e --- /dev/null +++ b/src/Snapshooter.NUnit/NUnitSnapshotBuilder.cs @@ -0,0 +1,25 @@ +using static Snapshooter.NUnit.Snapshot; + +namespace Snapshooter.NUnit +{ + internal class NUnitSnapshotBuilder : SnapshotBuilder + { + public NUnitSnapshotBuilder(object target) + : base(target.RemoveUnwantedWrappers()) + { + } + + public override void Match() + { + SnapshotFullName snapshotName = (SnapshotName, SnapshotNameExtension) switch + { + ({ }, null) => FullName(SnapshotName), + (null, { }) => FullName(SnapshotNameExtension), + ({ }, { }) => FullName(SnapshotName, SnapshotNameExtension), + _ => FullName() + }; + + Snapshot.Match(Target, snapshotName, ConfigureOptions); + } + } +} diff --git a/src/Snapshooter.NUnit/SnapshotExtension.cs b/src/Snapshooter.NUnit/SnapshotExtension.cs index b57d5f8..748bec3 100644 --- a/src/Snapshooter.NUnit/SnapshotExtension.cs +++ b/src/Snapshooter.NUnit/SnapshotExtension.cs @@ -1,4 +1,5 @@ using System; +using static Snapshooter.NUnit.Snapshot; namespace Snapshooter.NUnit { @@ -19,7 +20,7 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, matchOptions); + Match(cleanedObject, matchOptions); } /// @@ -47,7 +48,7 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotNameExtension, matchOptions); + Match(cleanedObject, snapshotNameExtension, matchOptions); } /// @@ -70,7 +71,7 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotName, matchOptions); + Match(cleanedObject, snapshotName, matchOptions); } /// @@ -103,18 +104,18 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotName, snapshotNameExtension, matchOptions); + Match(cleanedObject, snapshotName, snapshotNameExtension, matchOptions); } - /// - /// Creates a json snapshot of the given object and compares it with the - /// already existing snapshot of the test. + /// + /// Creates a json snapshot of the given object and compares it with the + /// already existing snapshot of the test. /// If no snapshot exists, a new snapshot will be created from the current result /// and saved under a certain file path, which will shown within the test message. /// /// The object to match. /// - /// The full name of a snapshot with folder and file name. + /// The full name of a snapshot with folder and file name. /// To get a SnapshotFullName use Snapshot.FullName(). /// /// Additional compare actions, which can be applied during the snapshot comparison. @@ -125,7 +126,15 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotFullName, matchOptions); + Match(cleanedObject, snapshotFullName, matchOptions); } + + /// + /// Initializes a builder to configure the snapshot + /// + /// + /// + public static ISnapshotBuilder Snapshot(this object target) => + new NUnitSnapshotBuilder(target); } } diff --git a/src/Snapshooter.Xunit/SnapshotExtension.cs b/src/Snapshooter.Xunit/SnapshotExtension.cs index 07b07ca..cd7680c 100644 --- a/src/Snapshooter.Xunit/SnapshotExtension.cs +++ b/src/Snapshooter.Xunit/SnapshotExtension.cs @@ -1,5 +1,7 @@ using System; +using System.Threading.Tasks; using Xunit; +using static Snapshooter.Xunit.Snapshot; namespace Snapshooter.Xunit { @@ -20,7 +22,7 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, matchOptions); + Match(cleanedObject, matchOptions); } /// @@ -48,7 +50,7 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotNameExtension, matchOptions); + Match(cleanedObject, snapshotNameExtension, matchOptions); } /// @@ -71,7 +73,7 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotName, matchOptions); + Match(cleanedObject, snapshotName, matchOptions); } /// @@ -104,18 +106,18 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotName, snapshotNameExtension, matchOptions); + Match(cleanedObject, snapshotName, snapshotNameExtension, matchOptions); } - /// - /// Creates a json snapshot of the given object and compares it with the - /// already existing snapshot of the test. + /// + /// Creates a json snapshot of the given object and compares it with the + /// already existing snapshot of the test. /// If no snapshot exists, a new snapshot will be created from the current result /// and saved under a certain file path, which will shown within the test message. /// /// The object to match. /// - /// The full name of a snapshot with folder and file name. + /// The full name of a snapshot with folder and file name. /// To get a SnapshotFullName use Snapshot.FullName(). /// /// Additional compare actions, which can be applied during the snapshot comparison. @@ -126,7 +128,15 @@ public static void MatchSnapshot( Func matchOptions = null) { var cleanedObject = currentResult.RemoveUnwantedWrappers(); - Snapshot.Match(cleanedObject, snapshotFullName, matchOptions); + Match(cleanedObject, snapshotFullName, matchOptions); } + + /// + /// Initializes a builder to configure the snapshot + /// + /// + /// + public static ISnapshotBuilder Snapshot(this object target) => + new XUnitSnapshotBuilder(target); } } diff --git a/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs b/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs new file mode 100644 index 0000000..8c880c0 --- /dev/null +++ b/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs @@ -0,0 +1,24 @@ +namespace Snapshooter.Xunit +{ + internal class XUnitSnapshotBuilder : SnapshotBuilder + { + public XUnitSnapshotBuilder(object target) + : base(target.RemoveUnwantedWrappers()) + { + } + + public override void Match() + { + SnapshotFullName snapshotName = + (_snapshotName: SnapshotName, snapshotNameExtension: SnapshotNameExtension) switch + { + ({ }, null) => Snapshot.FullName(SnapshotName), + (null, { }) => Snapshot.FullName(SnapshotNameExtension), + ({ }, { }) => Snapshot.FullName(SnapshotName, SnapshotNameExtension), + _ => Snapshot.FullName(), + }; + + Snapshot.Match(Target, snapshotName, ConfigureOptions); + } + } +} diff --git a/src/Snapshooter/ISnapshotBuilder.cs b/src/Snapshooter/ISnapshotBuilder.cs new file mode 100644 index 0000000..4f7dbd3 --- /dev/null +++ b/src/Snapshooter/ISnapshotBuilder.cs @@ -0,0 +1,33 @@ +using System; + +namespace Snapshooter +{ + public interface ISnapshotBuilder + { + /// + /// Configures the Match options of this snapshot + /// + /// + /// + ISnapshotBuilder ConfigureOptions(Func configure); + + /// + /// Configures the name of this snapshot + /// + /// + /// + ISnapshotBuilder Name(string extensions); + + /// + /// Configures the name extension + /// + /// + /// + ISnapshotBuilder NameExtension(SnapshotNameExtension extensions); + + /// + /// Takes a snapshot of the Target and validates it + /// + void Match(); + } +} diff --git a/src/Snapshooter/SnapshotBuilder.cs b/src/Snapshooter/SnapshotBuilder.cs new file mode 100644 index 0000000..16dbb82 --- /dev/null +++ b/src/Snapshooter/SnapshotBuilder.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Snapshooter +{ + /// + /// A builder to configure the snapshot + /// + public abstract class SnapshotBuilder + : ISnapshotBuilder + { + private readonly List> _optionsConfigurations = + new List>(); + + public SnapshotBuilder(object target) + { + Target = target; + } + + /// + /// The target that should be snapshoted + /// + protected object Target { get; } + + /// + /// The name of the snapshot file + /// + protected string SnapshotName { get; private set; } + + /// + /// The name extension of the snapshot + /// + protected SnapshotNameExtension SnapshotNameExtension { get; private set; } + + /// + /// Configures the Match options of this snapshot + /// + /// + /// + public ISnapshotBuilder ConfigureOptions(Func configure) + { + _optionsConfigurations.Add(configure); + return this; + } + + /// + /// Configures the name of this snapshot + /// + /// + /// + public ISnapshotBuilder Name(string extensions) + { + SnapshotName = extensions; + return this; + } + + /// + /// Configures the name extension + /// + /// + /// + public ISnapshotBuilder NameExtension(SnapshotNameExtension extensions) + { + SnapshotNameExtension = extensions; + return this; + } + + /// + /// Takes a snapshot of the Target and validates it + /// + public abstract void Match(); + + /// + /// Builds the MatchOptions based on the configuration + /// + /// + /// + protected MatchOptions ConfigureOptions(MatchOptions options) => + _optionsConfigurations.Aggregate(options, (current, configure) => configure(current)); + } +} diff --git a/src/Snapshooter/SnapshotBuilderExtensions.cs b/src/Snapshooter/SnapshotBuilderExtensions.cs new file mode 100644 index 0000000..0b1a711 --- /dev/null +++ b/src/Snapshooter/SnapshotBuilderExtensions.cs @@ -0,0 +1,159 @@ +using System; + +namespace Snapshooter +{ + public static class SnapshotBuilderExtensions + { + /// + /// With the option, you can ignore the given field + /// during snapshot comparison. Therefore the field will just be skipped during compare. + /// + /// The builder + /// The json path to the field to ignore. + public static ISnapshotBuilder IgnoreField(this ISnapshotBuilder builder, string fieldPath) + { + return builder.ConfigureOptions(x => x.IgnoreField(fieldPath)); + } + + /// + /// With the option, you can ignore the given fields + /// during snapshot comparison. Therefore the fields will just be skipped during compare. + /// + /// The builder + /// The json path to the fields to ignore. + public static ISnapshotBuilder IgnoreFields( + this ISnapshotBuilder builder, + string fieldsPath) + { + return builder.ConfigureOptions(x => x.IgnoreFields(fieldsPath)); + } + + /// + /// With the option, you can ignore the given field + /// during snapshot comparison. Therefore the field will just be skipped during compare. + /// + /// The builder + /// The json path to the field to ignore. + public static ISnapshotBuilder IgnoreField( + this ISnapshotBuilder builder, + string fieldPath) + { + return builder.ConfigureOptions(x => x.IgnoreField(fieldPath)); + } + + /// + /// With the option, you can ignore the given fields + /// during snapshot comparison. Therefore the fields will just be skipped during compare. + /// + /// The builder + /// The json path to the fields to ignore. + public static ISnapshotBuilder IgnoreFields( + this ISnapshotBuilder builder, + string fieldsPath) + { + return builder.ConfigureOptions(x => x.IgnoreFields(fieldsPath)); + } + + /// + /// With the option, you can ignore the given field during snapshot + /// comparison. Therefore the field will just be skipped during compare. + /// + /// The builder + /// The snapshot field to ignore. + public static ISnapshotBuilder Ignore( + this ISnapshotBuilder builder, + Func ignoreFieldOption) + { + return builder.ConfigureOptions(x => x.Ignore(ignoreFieldOption)); + } + + /// + /// The method IsType allows you during the snapshot comparison, + /// to check if a field is from a specific type. Therefore the given field will NOT + /// be compared with the field of the snapshot, it will only be checked if the + /// field has the given type. + /// + /// The type which the field should have. + /// The builder + /// The field to check. + public static ISnapshotBuilder IsType( + this ISnapshotBuilder builder, + Func isTypeField) + { + return builder.ConfigureOptions(x => x.IsType(isTypeField)); + } + + /// + /// The method IsType allows you during the snapshot comparison, + /// to check if a field is from a specific type. Therefore the given field will NOT + /// be compared with the field of the snapshot, it will only be checked if the + /// field has the given type. + /// + /// The type which the field should have. + /// The field to check. + /// The builder + public static ISnapshotBuilder IsType( + this ISnapshotBuilder builder, + Func isTypeField) + { + return builder.ConfigureOptions(x => x.IsType(isTypeField)); + } + + /// + /// The method allows you during the snapshot comparison, + /// to check if a field is from a specific type. Therefore the given field will NOT + /// be compared with the field of the snapshot, it will only be checked if the + /// field is from the given type. + /// + /// The type which the field should have. + /// The json path of the field to check for the type. + /// The builder + public static ISnapshotBuilder IsTypeField( + this ISnapshotBuilder builder, + string fieldPath) + { + return builder.ConfigureOptions(x => x.IgnoreField(fieldPath)); + } + + /// + /// The method allows you during the snapshot comparison, + /// to check if the given fields are from a specific type. Therefore the given fields + /// will NOT be compared with the fields of the snapshot, it will only be checked if the + /// fields are from the given type. + /// + /// The type which the field should have. + /// The json path of the fields to check for the type. + /// The builder + public static ISnapshotBuilder IsTypeFields( + this ISnapshotBuilder builder, + string fieldsPath) + { + return builder.ConfigureOptions(x => x.IsTypeFields(fieldsPath)); + } + + /// + /// The method allows you during the snapshot comparison, + /// to assert/validate a specific field separately. Therefore the given field + /// will NOT be compared with the fields of the snapshot, it will only be validated + /// with the assert function defined. + /// + /// + /// The validation action, which shall be executed + /// on the value of the field. + /// + /// The builder + public static ISnapshotBuilder Assert( + this ISnapshotBuilder builder, + Action assertAction) + { + return builder.ConfigureOptions(x => x.Assert(assertAction)); + } + + public static ISnapshotBuilder NameExtension( + this ISnapshotBuilder builder, + string extensions) + { + return builder.NameExtension(new SnapshotNameExtension(extensions)); + } + } +} diff --git a/src/Snapshooter/SnapshotFullNameResolver.cs b/src/Snapshooter/SnapshotFullNameResolver.cs index 29a9e41..e6001bd 100644 --- a/src/Snapshooter/SnapshotFullNameResolver.cs +++ b/src/Snapshooter/SnapshotFullNameResolver.cs @@ -12,12 +12,11 @@ public class SnapshotFullNameResolver : ISnapshotFullNameResolver private readonly ISnapshotFullNameReader _snapshotFullNameReader; /// - /// Constructor of the class + /// Constructor of the class /// initializes a new instance. /// /// The filename. - public SnapshotFullNameResolver( - ISnapshotFullNameReader snapshotFullNameReader) + public SnapshotFullNameResolver(ISnapshotFullNameReader snapshotFullNameReader) { _snapshotFullNameReader = snapshotFullNameReader; } @@ -32,30 +31,29 @@ public SnapshotFullName ResolveSnapshotFullName() } /// - /// Resolves the snapshot name for the running unit test. - /// The default generated snapshot name can be overwritten + /// Resolves the snapshot name for the running unit test. + /// The default generated snapshot name can be overwritten /// by the given snapshot name. /// /// - /// The snapshot name given by the user. This snapshot name will overwrite - /// the automatically generated snapshot name. + /// The snapshot name given by the user. This snapshot name will overwrite + /// the automatically generated snapshot name. /// /// The full name of a snapshot. - public SnapshotFullName ResolveSnapshotFullName( - string snapshotName) + public SnapshotFullName ResolveSnapshotFullName(string snapshotName) { return ResolveSnapshotFullName(snapshotName, null); } /// - /// Resolves the snapshot name for the running unit test. - /// The default generated snapshot name can either be overwritten + /// Resolves the snapshot name for the running unit test. + /// The default generated snapshot name can either be overwritten /// with a given snapshot name, or can be extended by the snapshot name extensions, /// or both. /// /// - /// The snapshot name given by the user, this snapshot name will overwrite - /// the automatically generated snapshot name. + /// The snapshot name given by the user, this snapshot name will overwrite + /// the automatically generated snapshot name. /// /// /// The snapshot name extension will extend the snapshot name with @@ -64,9 +62,10 @@ public SnapshotFullName ResolveSnapshotFullName( /// /// The full name of a snapshot. public SnapshotFullName ResolveSnapshotFullName( - string snapshotName, string snapshotNameExtension) + string snapshotName, + string snapshotNameExtension) { - SnapshotFullName snapshotFullName = + SnapshotFullName snapshotFullName = _snapshotFullNameReader.ReadSnapshotFullName(); if (snapshotFullName == null) @@ -75,8 +74,8 @@ public SnapshotFullName ResolveSnapshotFullName( "The snapshot full name could not be evaluated."); } - if(string.IsNullOrWhiteSpace(snapshotFullName.Filename) && - string.IsNullOrWhiteSpace(snapshotName)) + if (string.IsNullOrWhiteSpace(snapshotFullName.Filename) && + string.IsNullOrWhiteSpace(snapshotName)) { throw new SnapshotTestException( "No snapshot name could be resolved."); @@ -89,7 +88,7 @@ public SnapshotFullName ResolveSnapshotFullName( snapshotName = AddSnapshotNameExtension(snapshotName, snapshotNameExtension); snapshotName = EnsureSnapshotFileExtension(snapshotName); - + return new SnapshotFullName(snapshotName, snapshotFullName.FolderPath); } @@ -98,14 +97,14 @@ private string EnsureSnapshotFileExtension(string snapshotName) if (!snapshotName.EndsWith(FileNames.SnapshotFileExtension)) { snapshotName = string.Concat( - snapshotName, FileNames.SnapshotFileExtension); + snapshotName, + FileNames.SnapshotFileExtension); } return snapshotName; } - private string AddSnapshotNameExtension( - string snapshotName, string snapshotNameExtension) + private string AddSnapshotNameExtension(string snapshotName, string snapshotNameExtension) { if (snapshotNameExtension != null) { @@ -115,4 +114,4 @@ private string AddSnapshotNameExtension( return snapshotName; } } -} \ No newline at end of file +} From e458d2620600b27f40f81293cc54c0afbe08c943 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 13 Oct 2021 15:42:55 +0200 Subject: [PATCH 2/5] Cleanup --- src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs b/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs index 8c880c0..d4bfc25 100644 --- a/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs +++ b/src/Snapshooter.Xunit/XUnitSnapshotBuilder.cs @@ -1,3 +1,5 @@ +using static Snapshooter.Xunit.Snapshot; + namespace Snapshooter.Xunit { internal class XUnitSnapshotBuilder : SnapshotBuilder @@ -9,14 +11,13 @@ public XUnitSnapshotBuilder(object target) public override void Match() { - SnapshotFullName snapshotName = - (_snapshotName: SnapshotName, snapshotNameExtension: SnapshotNameExtension) switch - { - ({ }, null) => Snapshot.FullName(SnapshotName), - (null, { }) => Snapshot.FullName(SnapshotNameExtension), - ({ }, { }) => Snapshot.FullName(SnapshotName, SnapshotNameExtension), - _ => Snapshot.FullName(), - }; + SnapshotFullName snapshotName = (SnapshotName, SnapshotNameExtension) switch + { + ({ }, null) => FullName(SnapshotName), + (null, { }) => FullName(SnapshotNameExtension), + ({ }, { }) => FullName(SnapshotName, SnapshotNameExtension), + _ => FullName() + }; Snapshot.Match(Target, snapshotName, ConfigureOptions); } From dd4bba5a5c168d49d256fffed34f5a9ce0308332 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 13 Oct 2021 15:43:33 +0200 Subject: [PATCH 3/5] Add comments --- src/Snapshooter/ISnapshotBuilder.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Snapshooter/ISnapshotBuilder.cs b/src/Snapshooter/ISnapshotBuilder.cs index 4f7dbd3..530c284 100644 --- a/src/Snapshooter/ISnapshotBuilder.cs +++ b/src/Snapshooter/ISnapshotBuilder.cs @@ -2,6 +2,9 @@ namespace Snapshooter { + /// + /// A builder to configure the snapshot + /// public interface ISnapshotBuilder { /// From fbf8c3b963e18c387282a6dbb9dee19ec7bdd889 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 13 Oct 2021 15:49:46 +0200 Subject: [PATCH 4/5] Fix format --- src/Snapshooter/SnapshotBuilder.cs | 2 +- src/Snapshooter/SnapshotBuilderExtensions.cs | 7 +++++++ src/Snapshooter/SnapshotFullNameResolver.cs | 19 ++++++++++--------- src/Snapshooter/SnapshotNameExtension.cs | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Snapshooter/SnapshotBuilder.cs b/src/Snapshooter/SnapshotBuilder.cs index 16dbb82..171adfc 100644 --- a/src/Snapshooter/SnapshotBuilder.cs +++ b/src/Snapshooter/SnapshotBuilder.cs @@ -53,7 +53,7 @@ public ISnapshotBuilder Name(string extensions) { SnapshotName = extensions; return this; - } + }symotion-F2) /// /// Configures the name extension diff --git a/src/Snapshooter/SnapshotBuilderExtensions.cs b/src/Snapshooter/SnapshotBuilderExtensions.cs index 0b1a711..ba8a7f5 100644 --- a/src/Snapshooter/SnapshotBuilderExtensions.cs +++ b/src/Snapshooter/SnapshotBuilderExtensions.cs @@ -149,6 +149,13 @@ public static ISnapshotBuilder Assert( return builder.ConfigureOptions(x => x.Assert(assertAction)); } + /// + /// Configures the name extension. The value passed as will be + /// added to the + /// + /// The name of the extension + /// The builder + /// public static ISnapshotBuilder NameExtension( this ISnapshotBuilder builder, string extensions) diff --git a/src/Snapshooter/SnapshotFullNameResolver.cs b/src/Snapshooter/SnapshotFullNameResolver.cs index e6001bd..39bbdc6 100644 --- a/src/Snapshooter/SnapshotFullNameResolver.cs +++ b/src/Snapshooter/SnapshotFullNameResolver.cs @@ -16,7 +16,8 @@ public class SnapshotFullNameResolver : ISnapshotFullNameResolver /// initializes a new instance. /// /// The filename. - public SnapshotFullNameResolver(ISnapshotFullNameReader snapshotFullNameReader) + public SnapshotFullNameResolver( + ISnapshotFullNameReader snapshotFullNameReader) { _snapshotFullNameReader = snapshotFullNameReader; } @@ -40,7 +41,8 @@ public SnapshotFullName ResolveSnapshotFullName() /// the automatically generated snapshot name. /// /// The full name of a snapshot. - public SnapshotFullName ResolveSnapshotFullName(string snapshotName) + public SnapshotFullName ResolveSnapshotFullName( + string snapshotName) { return ResolveSnapshotFullName(snapshotName, null); } @@ -62,8 +64,7 @@ public SnapshotFullName ResolveSnapshotFullName(string snapshotName) /// /// The full name of a snapshot. public SnapshotFullName ResolveSnapshotFullName( - string snapshotName, - string snapshotNameExtension) + string snapshotName, string snapshotNameExtension) { SnapshotFullName snapshotFullName = _snapshotFullNameReader.ReadSnapshotFullName(); @@ -74,8 +75,8 @@ public SnapshotFullName ResolveSnapshotFullName( "The snapshot full name could not be evaluated."); } - if (string.IsNullOrWhiteSpace(snapshotFullName.Filename) && - string.IsNullOrWhiteSpace(snapshotName)) + if(string.IsNullOrWhiteSpace(snapshotFullName.Filename) && + string.IsNullOrWhiteSpace(snapshotName)) { throw new SnapshotTestException( "No snapshot name could be resolved."); @@ -97,14 +98,14 @@ private string EnsureSnapshotFileExtension(string snapshotName) if (!snapshotName.EndsWith(FileNames.SnapshotFileExtension)) { snapshotName = string.Concat( - snapshotName, - FileNames.SnapshotFileExtension); + snapshotName, FileNames.SnapshotFileExtension); } return snapshotName; } - private string AddSnapshotNameExtension(string snapshotName, string snapshotNameExtension) + private string AddSnapshotNameExtension( + string snapshotName, string snapshotNameExtension) { if (snapshotNameExtension != null) { diff --git a/src/Snapshooter/SnapshotNameExtension.cs b/src/Snapshooter/SnapshotNameExtension.cs index 773f50e..36e4f35 100644 --- a/src/Snapshooter/SnapshotNameExtension.cs +++ b/src/Snapshooter/SnapshotNameExtension.cs @@ -6,7 +6,7 @@ namespace Snapshooter { /// - /// A snapshot name extension will be transformed to a string, which will be + /// A snapshot name extension will be transformed to a string, which will be /// added to the end of the snapshot name. /// public class SnapshotNameExtension From bfe5704fd1d09746b4de780ae0b7a0ed0054b486 Mon Sep 17 00:00:00 2001 From: Pascal Senn Date: Wed, 13 Oct 2021 15:50:44 +0200 Subject: [PATCH 5/5] Fix format --- src/Snapshooter/SnapshotBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Snapshooter/SnapshotBuilder.cs b/src/Snapshooter/SnapshotBuilder.cs index 171adfc..16dbb82 100644 --- a/src/Snapshooter/SnapshotBuilder.cs +++ b/src/Snapshooter/SnapshotBuilder.cs @@ -53,7 +53,7 @@ public ISnapshotBuilder Name(string extensions) { SnapshotName = extensions; return this; - }symotion-F2) + } /// /// Configures the name extension