예제 #1
0
    public void should_build_no_arguments_for_default_constructor()
    {
        var unitType = typeof(SubjectClass);

        // --arrange
        var buildSession = A.Fake <IBuildSession>();

        A.CallTo(() => buildSession.BuildChain).Returns(Unit.IsType(unitType).ToBuildChain());
        var buildConstructor = A.CallTo(() => buildSession.BuildUnit(Kind.Is(unitType).Tag(SpecialTag.Constructor)));

        buildConstructor.Returns(new BuildResult(unitType.GetConstructors().Single(_ => _.GetParameters().Length == 0))); // default constructor

        var target = new CreateByReflection();

        // --act
        target.Process(buildSession);

        // --assert
        buildConstructor.MustHaveHappenedOnceExactly();
        A.CallTo(() => buildSession.BuildUnit(default)).WhenBuildAnyArguments().MustNotHaveHappened();