Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CSF.Screenplay.Abstractions/Abilities/GetAssetFilePaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CSF.Screenplay.Abilities
/// <summary>
/// Screenplay ability which gets the file system path for asset files generated by actors participating in the current performance.
/// </summary>
public class GetAssetFilePaths
public class GetAssetFilePaths : ICanReport
{
readonly IGetsAssetFilePath pathProvider;

Expand All @@ -27,6 +27,10 @@ public class GetAssetFilePaths
/// <seealso cref="IGetsAssetFilePath.GetAssetFilePath(string)"/>
public string GetAssetFilePath(string baseName) => pathProvider.GetAssetFilePath(baseName);

/// <inheritdoc/>
public ReportFragment GetReportFragment(Actor actor, IFormatsReportFragment formatter)
=> formatter.Format("{Actor} is able to get file system paths for assets", actor);

/// <summary>
/// Initializes a new instance of the <see cref="GetAssetFilePaths"/> class.
/// </summary>
Expand Down
27 changes: 27 additions & 0 deletions Tests/CSF.Screenplay.Tests/Abilities/GetAssetFilePathsTests.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
Loading