当前位置: 首页>>代码示例>>C#>>正文


C# IFoo.Baz方法代码示例

本文整理汇总了C#中IFoo.Baz方法的典型用法代码示例。如果您正苦于以下问题:C# IFoo.Baz方法的具体用法?C# IFoo.Baz怎么用?C# IFoo.Baz使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IFoo的用法示例。


在下文中一共展示了IFoo.Baz方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultipleCallbacks

        public static void MultipleCallbacks(
            IFoo fake,
            bool firstWasCalled,
            bool secondWasCalled,
            int returnValue)
        {
            "Given a fake"
                .x(() => fake = A.Fake<IFoo>());

            "And I configure a method to invoke two actions and return a value"
                .x(() =>
                    A.CallTo(() => fake.Baz())
                        .Invokes(x => firstWasCalled = true)
                        .Invokes(x => secondWasCalled = true)
                        .Returns(10));

            "When I call the method"
                .x(() => returnValue = fake.Baz());

            "Then it calls the first callback"
                .x(() => firstWasCalled.Should().BeTrue());

            "And it calls the first callback"
                .x(() => secondWasCalled.Should().BeTrue());

            "And it returns the configured value"
                .x(() => returnValue.Should().Be(10));
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:28,代码来源:ConfigurationSpecs.cs

示例2: MultipleCallbacks

        public static void MultipleCallbacks(
            IFoo fake,
            bool firstWasCalled,
            bool secondWasCalled,
            int returnValue)
        {
            "establish"
                .x(() => fake = A.Fake<IFoo>());

            "when configuring multiple callback"
                .x(() =>
                    {
                        A.CallTo(() => fake.Baz())
                            .Invokes(x => firstWasCalled = true)
                            .Invokes(x => secondWasCalled = true)
                            .Returns(10);

                        returnValue = fake.Baz();
                    });

            "it should call the first callback"
                .x(() => firstWasCalled.Should().BeTrue());

            "it should call the second callback"
                .x(() => secondWasCalled.Should().BeTrue());

            "it should return the configured value"
                .x(() => returnValue.Should().Be(10));
        }
开发者ID:bluePlayer,项目名称:FakeItEasy,代码行数:29,代码来源:ConfigurationSpecs.cs

示例3: MultipleReturns

        public static void MultipleReturns(
            IFoo fake,
            IReturnValueArgumentValidationConfiguration<int> configuration,
            Exception exception)
        {
            "establish"
                .x(() => fake = A.Fake<IFoo>());

            "when configuring multiple returns on the same configuration"
                .x(() =>
                {
                    configuration = A.CallTo(() => fake.Baz());
                    configuration.Returns(42);
                    exception = Record.Exception(() => configuration.Returns(0));
                });

            "it should throw an invalid operation exception"
                .x(() => exception.Should().BeAnExceptionOfType<InvalidOperationException>());
        }
开发者ID:bluePlayer,项目名称:FakeItEasy,代码行数:19,代码来源:ConfigurationSpecs.cs

示例4: MultipleReturns

        public static void MultipleReturns(
            IFoo fake,
            IReturnValueArgumentValidationConfiguration<int> configuration,
            Exception exception)
        {
            "Given a fake"
                .x(() => fake = A.Fake<IFoo>());

            "And I configure the return value for the method"
                .x(() =>
                {
                    configuration = A.CallTo(() => fake.Baz());
                    configuration.Returns(42);
                });

            "When I use the same configuration object to set the return value again"
                .x(() => exception = Record.Exception(() => configuration.Returns(0)));

            "Then it throws an invalid operation exception"
                .x(() => exception.Should().BeAnExceptionOfType<InvalidOperationException>());
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:21,代码来源:ConfigurationSpecs.cs

示例5: UnusedNonVoidCallSpec

        public static void UnusedNonVoidCallSpec(
            IFoo fake,
            Exception exception)
        {
            "Given a strict fake"
                .x(() => fake = A.Fake<IFoo>(o => o.Strict()));

            "When I specify a call to a void method without configuring its behavior"
                .x(() => A.CallTo(() => fake.Baz()));

            "And I make a call to that method"
                .x(() => exception = Record.Exception(() => fake.Baz()));

            "Then it throws an expectation exception"
                .x(() => exception.Should().BeAnExceptionOfType<ExpectationException>());
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:16,代码来源:ConfigurationSpecs.cs

示例6: InvokesAfterStrictValueType

        public static void InvokesAfterStrictValueType(
            IFoo fake,
            int result)
        {
            "Given a strict fake"
                .x(() => fake = A.Fake<IFoo>(options => options.Strict()));

            "And I configure a value type method to invoke an action"
                .x(() => A.CallTo(() => fake.Baz()).Invokes(() => { }));

            "When I call the method"
                .x(() => result = fake.Baz());

            "Then it returns a default instance of the value type"
                .x(() => result.Should().Be(0));
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:16,代码来源:ConfigurationSpecs.cs

示例7: DoesNothingAfterStrictValueType

        public static void DoesNothingAfterStrictValueType(
            IFoo fake,
            int result)
        {
            "Given a strict fake"
                .x(() => fake = A.Fake<IFoo>(options => options.Strict()));

            "And I configure all methods to do nothing"
                .x(() => A.CallTo(fake).DoesNothing());

            "When I call a value type method"
                .x(() => result = fake.Baz());

            "Then it returns a default instance of the value type"
                .x(() => result.Should().Be(0));
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:16,代码来源:ConfigurationSpecs.cs

示例8: MultipleThrows

        public static void MultipleThrows(
            IFoo fake,
            IReturnValueArgumentValidationConfiguration<int> configuration,
            Exception exception)
        {
            "establish"
                .x(() => fake = A.Fake<IFoo>());

            "when configuring a return then a throw on the same configuration"
                .x(() =>
                {
                    configuration = A.CallTo(() => fake.Baz());
                    configuration.Throws(new ArgumentNullException());
                    exception = Record.Exception(() => configuration.Throws(new ArgumentException()));
                });

            "it should throw an InvalidOperationException"
                .x(() => exception.Should().BeAnExceptionOfType<InvalidOperationException>());
        }
开发者ID:huoxudong125,项目名称:FakeItEasy,代码行数:19,代码来源:ConfigurationSpecs.cs

示例9: ReturnThenCallsBaseMethod

        public static void ReturnThenCallsBaseMethod(
            IFoo fake,
            IReturnValueArgumentValidationConfiguration<int> configuration,
            Exception exception)
        {
            "establish"
                .x(() => fake = A.Fake<IFoo>());

            "when configuring a return then base method call on the same configuration"
                .x(() =>
                {
                    configuration = A.CallTo(() => fake.Baz());
                    configuration.Returns(42);
                    exception = Record.Exception(() => configuration.CallsBaseMethod());
                });

            "it should throw an InvalidOperationException"
                .x(() => exception.Should().BeAnExceptionOfType<InvalidOperationException>());
        }
开发者ID:huoxudong125,项目名称:FakeItEasy,代码行数:19,代码来源:ConfigurationSpecs.cs

示例10: NonVoidMethodWithReturns

        public void NonVoidMethodWithReturns(
            IFoo foo,
            int result1,
            int result2,
            int result3)
        {
            "Given a fake"
                .x(() => foo = A.Fake<IFoo>());

            "When a non-void method is configured to return 1 once then return 2"
                .x(() =>
                    A.CallTo(() => foo.Baz()).Returns(1).Once()
                        .Then.Returns(2));

            "And the method is called 3 times"
                .x(() =>
                {
                    result1 = foo.Baz();
                    result2 = foo.Baz();
                    result3 = foo.Baz();
                });

            "Then the first call returns 1"
                .x(() => result1.Should().Be(1));

            "And the second call returns 2"
                .x(() => result2.Should().Be(2));

            "And the third call returns 2"
                .x(() => result3.Should().Be(2));
        }
开发者ID:adamralph,项目名称:FakeItEasy,代码行数:31,代码来源:ThenSpecs.cs


注:本文中的IFoo.Baz方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。