Skip to content

Commit 25f683b

Browse files
committed
Resolve #261 - This is now reportable
1 parent d6ba3e4 commit 25f683b

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

CSF.Screenplay.Abstractions/Abilities/GetAssetFilePaths.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace CSF.Screenplay.Abilities
55
/// <summary>
66
/// Screenplay ability which gets the file system path for asset files generated by actors participating in the current performance.
77
/// </summary>
8-
public class GetAssetFilePaths
8+
public class GetAssetFilePaths : ICanReport
99
{
1010
readonly IGetsAssetFilePath pathProvider;
1111

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

30+
/// <inheritdoc/>
31+
public ReportFragment GetReportFragment(Actor actor, IFormatsReportFragment formatter)
32+
=> formatter.Format("{Actor} is able to get file system paths for assets", actor);
33+
3034
/// <summary>
3135
/// Initializes a new instance of the <see cref="GetAssetFilePaths"/> class.
3236
/// </summary>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using CSF.Screenplay.Reporting;
2+
3+
namespace CSF.Screenplay.Abilities;
4+
5+
[TestFixture, Parallelizable]
6+
public class GetAssetFilePathsTests
7+
{
8+
[Test, AutoMoqData]
9+
public void GetAssetFilePathShouldReturnValueFromService([Frozen] IGetsAssetFilePath pathProvider,
10+
GetAssetFilePaths sut,
11+
string basePath,
12+
string expected)
13+
{
14+
Mock.Get(pathProvider).Setup(x => x.GetAssetFilePath(basePath)).Returns(expected);
15+
Assert.That(() => sut.GetAssetFilePath(basePath), Is.EqualTo(expected));
16+
}
17+
18+
[Test, AutoMoqData]
19+
public void GetReportFragmentShouldReturnValueFromFormatterUsingFormat(GetAssetFilePaths sut,
20+
Actor actor,
21+
IFormatsReportFragment formatter,
22+
ReportFragment expected)
23+
{
24+
Mock.Get(formatter).Setup(x => x.Format("{Actor} is able to get file system paths for assets", actor)).Returns(expected);
25+
Assert.That(() => sut.GetReportFragment(actor, formatter), Is.EqualTo(expected));
26+
}
27+
}

0 commit comments

Comments
 (0)