GuardClauseAssertion does not fail if limited to only public constructors

Viewed 24

Why does this unit test not fail when no guard clause is present?

  [Test]
  public void ConstructorLooksGuardedAgainstNulls()
  {
    // ARRANGE
    var fixture = new Fixture();
    var assertion = fixture.Create<GuardClauseAssertion>();

    // ACT & ASSERT
    assertion.Verify(typeof(TestClass).GetConstructors(BindingFlags.Public));
  }

Classes used in unit test:

  public class TestBaseClass
  {
    private readonly string _firstDependency;
    private readonly string _secondDependency;

    protected TestBaseClass(string firstDependency, string secondDependency)
    {
      _firstDependency = firstDependency;
      _secondDependency = secondDependency;
    }
  }

  public class TestClass : TestBaseClass
  {
    public TestClass(string firstDependency)
      : base(firstDependency, string.Empty)
    {
    }
  }

I removed all the irrelevant lines.

0 Answers
Related