Skip to content

Commit

Permalink
ValuesRequest tests improvments +semver: feature
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrzajac committed Dec 5, 2023
1 parent 9055ff2 commit 154ff08
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void GivenUninitializedValuesArgument_WhenConstructorIsInvoked_ThenExcept
Assert.Throws<ArgumentNullException>(() => new FixedValuesRequest(type, values));
}

[Fact(DisplayName = "GIVEN empty argument WHEN constructor is invoked THEN exception is thrown")]
public void GivenEmptyArgument_WhenConstructorIsInvoked_ThenExceptionIsThrown()
[Fact(DisplayName = "GIVEN empty values argument WHEN constructor is invoked THEN exception is thrown")]
public void GivenEmptyValuesArgument_WhenConstructorIsInvoked_ThenExceptionIsThrown()
{
// Arrange
var type = typeof(int);
Expand All @@ -66,19 +66,18 @@ public void GivenEmptyArgument_WhenConstructorIsInvoked_ThenExceptionIsThrown()

[InlineData(typeof(int), 2)]
[InlineData(1, typeof(int))]
[Theory(DisplayName = "GIVEN incomparable argument WHEN constructor is invoked THEN parameters are properly assigned")]
public void GivenIncomparableArgument_WhenConstructorIsInvoked_ThenParametersAreProperlyAssigned(
object first,
object second)
[Theory(DisplayName = "GIVEN different type arguments WHEN constructor is invoked THEN parameters are properly assigned")]
public void GivenDifferentTypeArguments_WhenConstructorIsInvoked_ThenParametersAreProperlyAssigned(
params object[] values)
{
// Arrange
var type = typeof(int);

// Act
var attribute = new FixedValuesRequest(type, first, second);
var attribute = new FixedValuesRequest(type, values);

// Assert
attribute.Values.Should().HaveCount(2).And.BeEquivalentTo(new[] { first, second });
attribute.Values.Should().HaveCount(2).And.BeEquivalentTo(values);
}

[Fact(DisplayName = "GIVEN valid arguments WHEN ToString is invoked THEN text conteins necessary information")]
Expand Down Expand Up @@ -126,8 +125,8 @@ public void GivenTwoRequests_WhenEqualsIsInvoked_ThenExpectedValueIsReturned(
}

[MemberData(nameof(ComparisonTestData))]
[Theory(DisplayName = "GIVEN two requests WHEN GetHashCode is invoked THEN expected value is returned")]
public void GivenTwoRequests_WhenGetHashCodeIsInvoked_ThenExpectedValueIsReturned(
[Theory(DisplayName = "GIVEN two requests WHEN hashcodes are compared THEN expected value is returned")]
public void GivenTwoRequests_WhenHashCodesAreCompared_ThenExpectedValueIsReturned(
Type typeA,
IEnumerable valuesA,
Type typeB,
Expand All @@ -148,7 +147,7 @@ public void GivenTwoRequests_WhenGetHashCodeIsInvoked_ThenExpectedValueIsReturne
}

[Fact(DisplayName = "GIVEN uninitialized request WHEN Equals is invoked THEN False is returned")]
[SuppressMessage("Maintainability", "CA1508:Avoid dead conditional code", Justification = "Test the logic")]
[SuppressMessage("Maintainability", "CA1508:Avoid dead conditional code", Justification = "Required to test the logic")]
public void GivenUninitializedRequest_WhenEqualsIsInvoked_ThenFalseIsReturned()
{
// Arrange
Expand All @@ -159,7 +158,7 @@ public void GivenUninitializedRequest_WhenEqualsIsInvoked_ThenFalseIsReturned()
var result = initialized.Equals(uninitialized);

// Assert
result.Should().Be(false);
result.Should().BeFalse();
}

[Fact(DisplayName = "GIVEN different type of object WHEN Equals is invoked THEN False is returned")]
Expand All @@ -173,7 +172,7 @@ public void GivenDifferentTypeOfObject_WhenEqualsIsInvoked_ThenFalseIsReturned()
var result = request.Equals(differentObject);

// Assert
result.Should().Be(false);
result.Should().BeFalse();
}

[AutoData]
Expand All @@ -191,13 +190,13 @@ public void GivenDifferentTypeOfValuesRequest_WhenEqualsIsInvoked_ThenFalseIsRet
var text = fixedRequest.ToString();

// Assert
result.Should().Be(false);
result.Should().BeFalse();
text.Should().NotBeNull();
}

[AutoData]
[Theory(DisplayName = "GIVEN different type of ValuesRequest WHEN hashcodes are compared THEN hashcodes are not equal")]
public void GivenDifferentTypeOfValuesRequest_WhenHashCodesAreCompared_ThenHashCodesAreNotEqual(
[Theory(DisplayName = "GIVEN ValuesRequests of different type WHEN hashcodes are compared THEN hashcodes are not equal")]
public void GivenValuesRequestsOfDifferentType_WhenHashCodesAreCompared_ThenHashCodesAreNotEqual(
int value)
{
// Arrange
Expand All @@ -211,7 +210,7 @@ public void GivenDifferentTypeOfValuesRequest_WhenHashCodesAreCompared_ThenHashC
var result = hashA == hashB;

// Assert
result.Should().Be(false);
result.Should().BeFalse();
}

[InlineAutoData(typeof(ExceptValuesRequest))]
Expand Down

0 comments on commit 154ff08

Please sign in to comment.