From 25f683bb5402e41fc41496240d4748ec77dd074e Mon Sep 17 00:00:00 2001 From: Craig Fowler Date: Sun, 18 Jan 2026 15:23:15 +0000 Subject: [PATCH] Resolve #261 - This is now reportable --- .../Abilities/GetAssetFilePaths.cs | 6 ++++- .../Abilities/GetAssetFilePathsTests.cs | 27 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Tests/CSF.Screenplay.Tests/Abilities/GetAssetFilePathsTests.cs diff --git a/CSF.Screenplay.Abstractions/Abilities/GetAssetFilePaths.cs b/CSF.Screenplay.Abstractions/Abilities/GetAssetFilePaths.cs index 4ab345a6..d892be4d 100644 --- a/CSF.Screenplay.Abstractions/Abilities/GetAssetFilePaths.cs +++ b/CSF.Screenplay.Abstractions/Abilities/GetAssetFilePaths.cs @@ -5,7 +5,7 @@ namespace CSF.Screenplay.Abilities /// /// Screenplay ability which gets the file system path for asset files generated by actors participating in the current performance. /// - public class GetAssetFilePaths + public class GetAssetFilePaths : ICanReport { readonly IGetsAssetFilePath pathProvider; @@ -27,6 +27,10 @@ public class GetAssetFilePaths /// public string GetAssetFilePath(string baseName) => pathProvider.GetAssetFilePath(baseName); + /// + public ReportFragment GetReportFragment(Actor actor, IFormatsReportFragment formatter) + => formatter.Format("{Actor} is able to get file system paths for assets", actor); + /// /// Initializes a new instance of the class. /// diff --git a/Tests/CSF.Screenplay.Tests/Abilities/GetAssetFilePathsTests.cs b/Tests/CSF.Screenplay.Tests/Abilities/GetAssetFilePathsTests.cs new file mode 100644 index 00000000..9eaa6486 --- /dev/null +++ b/Tests/CSF.Screenplay.Tests/Abilities/GetAssetFilePathsTests.cs @@ -0,0 +1,27 @@ +using CSF.Screenplay.Reporting; + +namespace CSF.Screenplay.Abilities; + +[TestFixture, Parallelizable] +public class GetAssetFilePathsTests +{ + [Test, AutoMoqData] + public void GetAssetFilePathShouldReturnValueFromService([Frozen] IGetsAssetFilePath pathProvider, + GetAssetFilePaths sut, + string basePath, + string expected) + { + Mock.Get(pathProvider).Setup(x => x.GetAssetFilePath(basePath)).Returns(expected); + Assert.That(() => sut.GetAssetFilePath(basePath), Is.EqualTo(expected)); + } + + [Test, AutoMoqData] + public void GetReportFragmentShouldReturnValueFromFormatterUsingFormat(GetAssetFilePaths sut, + Actor actor, + IFormatsReportFragment formatter, + ReportFragment expected) + { + Mock.Get(formatter).Setup(x => x.Format("{Actor} is able to get file system paths for assets", actor)).Returns(expected); + Assert.That(() => sut.GetReportFragment(actor, formatter), Is.EqualTo(expected)); + } +} \ No newline at end of file