Esempio n. 1
0
        public static void FailingMatchOfGenericCalls(
            IHaveTwoGenericParameters fake,
            Exception exception)
        {
            "Given a fake"
            .x(() => fake = A.Fake <IHaveTwoGenericParameters>());

            "And a call with arguments of type int and double made on this fake"
            .x(() => fake.Bar(1, 2D));

            "And a call with arguments of type Generic<bool, long> and int made on this call"
            .x(() => fake.Bar(new Generic <bool, long>(), 3));

            "When I assert that a call with arguments of type string and string has happened on this fake"
            .x(() => exception = Record.Exception(() => A.CallTo(() => fake.Bar(A <string> .Ignored, A <string> .Ignored)).MustHaveHappened()));

            "Then the assertion should fail"
            .x(() => exception.Should().BeAnExceptionOfType <ExpectationException>());

            "And the exception message should tell us that the call was not matched"
            .x(() => exception.Message.Should().Be(@"

  Assertion failed for the following call:
    FakeItEasy.Specs.CallMatchingSpecs+IHaveTwoGenericParameters.Bar`2[System.String,System.String](baz1: <Ignored>, baz2: <Ignored>)
  Expected to find it at least once but found it #0 times among the calls:
    1: FakeItEasy.Specs.CallMatchingSpecs+IHaveTwoGenericParameters.Bar`2[System.Int32,System.Double](baz1: 1, baz2: 2)
    2: FakeItEasy.Specs.CallMatchingSpecs+IHaveTwoGenericParameters.Bar`2[FakeItEasy.Specs.CallMatchingSpecs+Generic`2[System.Boolean,System.Int64],System.Int32](baz1: FakeItEasy.Specs.CallMatchingSpecs+Generic`2[System.Boolean,System.Int64], baz2: 3)

"));
        }
Esempio n. 2
0
        public static void FailingMatchOfGenericCalls(
            IHaveTwoGenericParameters fake,
            Exception exception)
        {
            "establish"
            .x(() => fake = A.Fake <IHaveTwoGenericParameters>());

            "when failing to match generic calls"
            .x(() =>
            {
                fake.Bar(1, 2D);
                fake.Bar(new Generic <bool, long>(), 3);
                exception = Record.Exception(() => A.CallTo(() => fake.Bar(A <string> .Ignored, A <string> .Ignored)).MustHaveHappened());
            });

            "it should tell us that the call was not matched"
            .x(() => exception.Message.Should().Be(
                   @"

  Assertion failed for the following call:
    FakeItEasy.Specs.CallMatchingSpecs+IHaveTwoGenericParameters.Bar<System.String, System.String>(<Ignored>, <Ignored>)
  Expected to find it at least once but found it #0 times among the calls:
    1: FakeItEasy.Specs.CallMatchingSpecs+IHaveTwoGenericParameters.Bar<System.Int32, System.Double>(baz1: 1, baz2: 2)
    2: FakeItEasy.Specs.CallMatchingSpecs+IHaveTwoGenericParameters.Bar<FakeItEasy.Specs.CallMatchingSpecs+Generic<System.Boolean, System.Int64>, System.Int32>(baz1: FakeItEasy.Specs.CallMatchingSpecs+Generic`2[System.Boolean,System.Int64], baz2: 3)

"));
        }