Skip to content

Commit 2d765ee

Browse files
authored
refactor: Improved coverage to 100%.
1 parent 46858f8 commit 2d765ee

3 files changed

Lines changed: 22 additions & 34 deletions

File tree

src/Heleonix.Testing.NUnit/Bdd/StoryAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public sealed class StoryAttribute : FixtureAttribute
6464
/// </value>
6565
protected override IDictionary<string, object> Properties => new Dictionary<string, object>
6666
{
67-
{ TestPropertiesHelper.OutputPropertyName(nameof(this.TestName)), $"{this.TestName}" },
67+
{ TestPropertiesHelper.OutputPropertyName(nameof(this.TestName)), this.TestName },
6868
};
6969

7070
/// <summary>

test/Heleonix.Testing.NUnit.Tests/Aaa/ComponentTestAttributeTests.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class ComponentTestAttributeTests
2323
/// <summary>
2424
/// Tests the <see cref="ComponentTestAttribute.TestName"/>.
2525
/// </summary>
26-
[Test(Description = "When a component type is provided Should return the test name")]
26+
[Test(Description = "When a component type is provided Should return the test name and corresponding properties")]
2727
public static void TestName1()
2828
{
2929
// Arrange
@@ -34,14 +34,19 @@ public static void TestName1()
3434
"TestName",
3535
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentTestAttribute) as string;
3636

37+
var properties = componentTestAttribute.GetType().GetProperty(
38+
"Properties",
39+
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentTestAttribute) as IDictionary<string, object>;
40+
3741
// Assert
3842
Assert.That(testName, Is.EqualTo("Int32"));
43+
Assert.That(properties["Heleonix.Testing.NUnit.Internal.Output.Type"], Is.EqualTo("Int32"));
3944
}
4045

4146
/// <summary>
4247
/// Tests the <see cref="ComponentTestAttribute.TestName"/>.
4348
/// </summary>
44-
[Test(Description = "When a component type is not provided Should return null")]
49+
[Test(Description = "When a component type is not provided Should return null and corresponding properties")]
4550
public static void TestName2()
4651
{
4752
// Arrange
@@ -52,8 +57,13 @@ public static void TestName2()
5257
"TestName",
5358
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentTestAttribute) as string;
5459

60+
var properties = componentTestAttribute.GetType().GetProperty(
61+
"Properties",
62+
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentTestAttribute) as IDictionary<string, object>;
63+
5564
// Assert
5665
Assert.That(testName, Is.Null);
66+
Assert.That(properties["Heleonix.Testing.NUnit.Internal.Output.Type"], Is.Null);
5767
}
5868
}
5969
}

test/Heleonix.Testing.NUnit.Tests/Bdd/StoryAttributeTests.cs

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,24 @@ public static class StoryAttributeTests
2020
/// <summary>
2121
/// Tests the <see cref="StoryAttribute.TestName"/>.
2222
/// </summary>
23-
[Test(Description = "When an id and summary are provided Should return the test name")]
23+
[Test(Description = "When an id and summary are provided Should return the test name and corresponding properties")]
2424
public static void TestName()
2525
{
2626
// Arrange
27-
var componentTestAttribute = new StoryAttribute { Id = "ID-123", Summary = "Some summary" };
27+
var storyTestAttribute = new StoryAttribute { Id = "ID-123", Summary = "Some summary" };
2828

2929
// Act
30-
var testName = componentTestAttribute.GetType().GetProperty(
30+
var testName = storyTestAttribute.GetType().GetProperty(
3131
nameof(TestName),
32-
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentTestAttribute) as string;
32+
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(storyTestAttribute) as string;
3333

34-
// Assert
35-
Assert.That(testName, Is.EqualTo("ID-123: Some summary"));
36-
}
37-
38-
/// <summary>
39-
/// Tests the <see cref="StoryAttribute.Properties"/>.
40-
/// </summary>
41-
[Test(Description = "When an AsA, IWant, SoThat are provided Should return properties with those statements")]
42-
public static void Properties()
43-
{
44-
// Arrange
45-
var componentTestAttribute = new StoryAttribute
46-
{
47-
Id = "ID-1",
48-
Summary = "Summary",
49-
AsA = "PO",
50-
IWant = "Everything",
51-
SoThat = "I'm ok",
52-
};
53-
54-
// Act
55-
var properties = componentTestAttribute.GetType().GetProperty(
56-
nameof(Properties),
57-
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(componentTestAttribute)
58-
as IDictionary<string, object>;
34+
var properties = storyTestAttribute.GetType().GetProperty(
35+
"Properties",
36+
BindingFlags.Instance | BindingFlags.NonPublic).GetValue(storyTestAttribute) as IDictionary<string, object>;
5937

6038
// Assert
61-
Assert.That(properties.Count, Is.EqualTo(1));
62-
Assert.That(properties["Heleonix.Testing.NUnit.Internal.Output.TestName"], Is.EqualTo("ID-1: Summary"));
39+
Assert.That(testName, Is.EqualTo("ID-123: Some summary"));
40+
Assert.That(properties["Heleonix.Testing.NUnit.Internal.Output.TestName"], Is.EqualTo("ID-123: Some summary"));
6341
}
6442
}
6543
}

0 commit comments

Comments
 (0)