Skip to content

[Bug]: Type checking doesn't work as described in docs #6710

Description

@bugs-wkettlitz

Description

https://tunit.dev/docs/assertions/getting-started/#type-checking

await Assert.That(typeof(Dog)).IsAssignableTo<Animal>();

Expected Behavior

Assertion succeeds if typeof(Dog).IsAssignableTo(typeof(Animal)) is true.

Actual Behavior

Assetion fails:

[Assertion Failure] Expected to be assignable to Animal
but type RuntimeType is not assignable to Animal

Steps to Reproduce

public class Animal { }

public class Dog: Animal {}
await Assert.That(typeof(Dog)).IsAssignableTo<Animal>();

TUnit Version

1.65.68

.NET Version

.net 10

Operating System

Windows

IDE / Test Runner

JetBrains Rider

Error Output / Stack Trace

[Assertion Failure] Expected to be assignable to Animal
but type RuntimeType is not assignable to Animal

Additional Context

Workaround:

await Assert
  .That(typeof(Dog).IsAssignableTo(typeof(Animal))
  .IsTrue();

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions