Skip to content

Commit

Permalink
Made TypeDescriptionUtility.GetTypeDescription non-discoverable, as n…
Browse files Browse the repository at this point in the history
…othing _currently_ has a need to get a description for a Type directly.
  • Loading branch information
logiclrd committed Mar 16, 2022
1 parent 0216b32 commit 8642245
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
2 changes: 1 addition & 1 deletion Src/FluentAssertions/TypeDescriptionUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static string GetDescriptionOfObjectType(object obj)
return (obj is null) ? "<null>" : GetTypeDescription(obj.GetType());
}

public static string GetTypeDescription(Type type)
private static string GetTypeDescription(Type type)
{
return
((type.Namespace == "System.Linq") && type.IsGenericType)
Expand Down
43 changes: 0 additions & 43 deletions Tests/FluentAssertions.Specs/TypeDescriptionUtilitySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,49 +57,6 @@ public void When_object_is_LINQ_anonymous_iterator_type_it_should_work()
"an anonymous iterator from a LINQ expression with element type System.Int32");
}

[Fact]
public void When_type_is_value_type_it_should_work()
{
// Act & Assert
TypeDescriptionUtility.GetTypeDescription(typeof(int)).Should().Be("a value of type System.Int32");
}

[Fact]
public void When_type_is_reference_type_it_should_work()
{
// Act & Assert
TypeDescriptionUtility.GetTypeDescription(typeof(object)).Should().Be("an instance of System.Object");
}

[Fact]
public void When_type_is_generic_value_type_it_should_work()
{
// Arrange
var value = new Box<int>() { Value = 37 };

// Act & Assert
TypeDescriptionUtility.GetTypeDescription(value.GetType()).Should()
.Match("a value of type *+Box`1[[System.Int32*]]");
}

[Fact]
public void When_type_is_generic_reference_type_it_should_work()
{
// Act & Assert
TypeDescriptionUtility.GetTypeDescription(typeof(List<int>)).Should()
.Match("an instance of System.Collections.Generic.List`1[[System.Int32*]]");
}

[Fact]
public void When_type_is_LINQ_anonymous_iterator_type_it_should_work()
{
// Arrange
var value = new[] { 1, 2, 3 }.Select(x => 2 * x);

TypeDescriptionUtility.GetTypeDescription(value.GetType()).Should().Be(
"an anonymous iterator from a LINQ expression with element type System.Int32");
}

private struct Box<T>
{
public T Value { get; set; }
Expand Down

0 comments on commit 8642245

Please sign in to comment.