From 294a6e7961f9b8b123156c56a3d59cfb0fd4dd46 Mon Sep 17 00:00:00 2001 From: Piotr Zajac Date: Fri, 4 Oct 2024 16:01:25 +0200 Subject: [PATCH] Improve test coverage by implementing positive scenario for converting data in MemberAutoDataBaseAttribute --- .../MemberAutoDataBaseAttributeTests.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Objectivity.AutoFixture.XUnit2.Core.Tests/Attributes/MemberAutoDataBaseAttributeTests.cs b/src/Objectivity.AutoFixture.XUnit2.Core.Tests/Attributes/MemberAutoDataBaseAttributeTests.cs index 3d5e7f73..dee1f29e 100644 --- a/src/Objectivity.AutoFixture.XUnit2.Core.Tests/Attributes/MemberAutoDataBaseAttributeTests.cs +++ b/src/Objectivity.AutoFixture.XUnit2.Core.Tests/Attributes/MemberAutoDataBaseAttributeTests.cs @@ -47,8 +47,8 @@ public void GivenUninitializedFixture_WhenConstructorIsInvoked_ThenExceptionIsTh } [MemberData(nameof(MemberTypeTestData))] - [Theory(DisplayName = "GIVEN item of unexpected type WHEN Convert is invoked THEN exception is thrown")] - public void GivenItemOfUnexpectedType_WhenConvertIsInvoked_ThenExceptionIsThrown( + [Theory(DisplayName = "GIVEN item of unexpected type WHEN ConvertDataItem is invoked THEN exception is thrown")] + public void GivenItemOfUnexpectedType_WhenConvertDataItemIsInvoked_ThenExceptionIsThrown( Type memberType, string expectedTypeName) { @@ -67,6 +67,21 @@ public void GivenItemOfUnexpectedType_WhenConvertIsInvoked_ThenExceptionIsThrown .And.Contain(memberName).And.Contain(expectedTypeName); } + [Fact(DisplayName = "GIVEN array WHEN ConvertDataItem is invoked THEN the same array is returned")] + public void GivenArray_WhenConvertDataItemIsInvoked_ThenTheSameArrayIsReturned() + { + // Arrange + var fixture = new Fixture(); + var array = fixture.Create(); + var attribute = new MemberAutoDataBaseAttributeUnderTest(fixture, nameof(NullTheoryData)); + + // Act + var data = attribute.CallConvertDataItem(TestMethod, array); + + // Assert + data.Should().BeEquivalentTo(array); + } + [Fact(DisplayName = "GIVEN null theory data WHEN GetData is invoked THEN null is returned")] public void GivenNullItem_WhenGetDataIsInvoked_ThenNullIsReturned() {