コード例 #1
0
        public static void ArgumentMismatchNonVoid(
            IMyInterface fake,
            Exception exception)
        {
            "Given a strict fake"
            .x(() => fake = A.Fake <IMyInterface>(o => o.Strict()));

            "And I configure the fake to return a value when a non-void method is called with certain arguments"
            .x(() => A.CallTo(() => fake.MakeIt("empty")).Returns(Guid.Empty));

            "When I call the method with non-matching arguments"
            .x(() => exception = Record.Exception(() => fake.MakeIt("something")));

            "Then the fake throws an expectation exception"
            .x(() => exception.Should().BeAnExceptionOfType <ExpectationException>());

            "And the exception message describes the call"
            .x(() => exception.Message.Should().Be(
                   @"Call to unconfigured method of strict fake: FakeItEasy.Specs.StrictFakeSpecs+IMyInterface.MakeIt(name: ""something"")."));
        }