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


C# ILibraryService.GetCount方法代码示例

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


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

示例1: SelfInitializingWithFileRecorder

        public void SelfInitializingWithFileRecorder(
            string fileRecorderPath,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            int countWhileRecording,
            int countDuringPlayback)
        {
            "establish"
                .x(() =>
                    {
                        fileRecorderPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());

                        realServiceWhileRecording = A.Fake<ILibraryService>();
                        realServiceDuringPlayback = A.Fake<ILibraryService>();

                        A.CallTo(() => realServiceWhileRecording.GetCount("9780345813923")).Returns(8);
                    });

            "when self initializing a fake with a FileRecorder"
                .x(() =>
                    {
                        try
                        {
                            using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                            {
                                var fakeService = A.Fake<ILibraryService>(options => options
                                    .Wrapping(realServiceWhileRecording).RecordedBy(recorder));
                                countWhileRecording = fakeService.GetCount("9780345813923");
                            }

                            using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                            {
                                var playbackFakeService = A.Fake<ILibraryService>(options => options
                                    .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                                countDuringPlayback = playbackFakeService.GetCount("9780345813923");
                            }
                        }
                        finally
                        {
                            File.Delete(fileRecorderPath);
                        }
                    })
                .Teardown(() => File.Delete(fileRecorderPath));

            "it should return the expected result while recording"
                .x(() => countWhileRecording.Should().Be(8));

            "it should return the recorded result during playback"
                .x(() => countDuringPlayback.Should().Be(8));
        }
开发者ID:ursenzler,项目名称:FakeItEasy,代码行数:51,代码来源:SelfInitializedFakes.cs

示例2: SelfInitializing

        public void SelfInitializing(
            InMemoryStorage inMemoryStorage,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            int count1ForBook1WhileRecording,
            int count1ForBook1DuringPlayback,
            int count2ForBook1DuringPlayback,
            int count1ForBook2DuringPlayback)
        {
            "establish"
                .x(() =>
                    {
                        inMemoryStorage = new InMemoryStorage();

                        realServiceWhileRecording = A.Fake<ILibraryService>();
                        realServiceDuringPlayback = A.Fake<ILibraryService>();

                        A.CallTo(() => realServiceWhileRecording.GetCount("9780345813923"))
                            .ReturnsNextFromSequence(11, 10);
                        A.CallTo(() => realServiceWhileRecording.GetCount("9781593078225"))
                            .Returns(3);
                    });

            "when self initializing a fake"
                .x(() =>
                    {
                        using (var recorder = new RecordingManager(inMemoryStorage))
                        {
                            var fakeService = A.Fake<ILibraryService>(options => options
                                .Wrapping(realServiceWhileRecording).RecordedBy(recorder));

                            count1ForBook1WhileRecording = fakeService.GetCount("9780345813923");
                            fakeService.GetCount("9781593078225");
                            fakeService.GetCount("9780345813923");
                        }

                        using (var recorder = new RecordingManager(inMemoryStorage))
                        {
                            var playbackFakeService = A.Fake<ILibraryService>(options => options
                                .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                            count1ForBook1DuringPlayback = playbackFakeService.GetCount("9780345813923");
                            count1ForBook2DuringPlayback = playbackFakeService.GetCount("9781593078225");
                            count2ForBook1DuringPlayback = playbackFakeService.GetCount("9780345813923");
                        }
                    });

            "it should forward calls to the wrapped service while recording"
                .x(() => A.CallTo(() => realServiceWhileRecording.GetCount("9780345813923"))
                             .MustHaveHappened(Repeated.Exactly.Twice));

            "it should return the result while recording"
                .x(() => count1ForBook1WhileRecording.Should().Be(11));

            "it should not forward calls to the wrapped service during playback"
                .x(() => A.CallTo(realServiceDuringPlayback).MustNotHaveHappened());

            "it should return the recorded result for the first set of arguments"
                .x(() => count1ForBook1DuringPlayback.Should().Be(11));

            "it should return the recorded result for the second set of arguments"
                .x(() => count1ForBook2DuringPlayback.Should().Be(3));

            "it should return the second recorded result when arguments are repeated"
                .x(() => count2ForBook1DuringPlayback.Should().Be(10));
        }
开发者ID:ursenzler,项目名称:FakeItEasy,代码行数:66,代码来源:SelfInitializedFakes.cs

示例3: SelfInitializing

        public static void SelfInitializing(
            InMemoryStorage inMemoryStorage,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            IEnumerable<int> countsWhileRecording,
            IEnumerable<int> countsDuringPlayback)
        {
            "Given a call storage object"
                .x(() => inMemoryStorage = new InMemoryStorage());

            "And a real service to wrap while recording"
                .x(() =>
                {
                    realServiceWhileRecording = A.Fake<ILibraryService>();

                    A.CallTo(() => realServiceWhileRecording.GetCount("1"))
                        .ReturnsNextFromSequence(0x1A, 0x1B);
                    A.CallTo(() => realServiceWhileRecording.GetCount("2"))
                        .Returns(0x2);
                });

            "And a real service to wrap while playing back"
                .x(() => realServiceDuringPlayback = A.Fake<ILibraryService>());

            "When I use a self-initialized fake in recording mode to get the counts for book 1, 2, and 1 again"
                .x(() =>
                    {
                        using (var recorder = new RecordingManager(inMemoryStorage))
                        {
                            var fakeService = A.Fake<ILibraryService>(options => options
                                .Wrapping(realServiceWhileRecording).RecordedBy(recorder));

                            countsWhileRecording = new List<int>
                            {
                                fakeService.GetCount("1"),
                                fakeService.GetCount("2"),
                                fakeService.GetCount("1")
                            };
                        }
                    });

            "And I use a self-initialized fake in playback mode to get the counts for book 1, 2, and 1 again"
                .x(() =>
                    {
                        using (var recorder = new RecordingManager(inMemoryStorage))
                        {
                            var playbackFakeService = A.Fake<ILibraryService>(options => options
                                .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                            countsDuringPlayback = new List<int>
                            {
                                playbackFakeService.GetCount("1"),
                                playbackFakeService.GetCount("2"),
                                playbackFakeService.GetCount("1")
                            };
                        }
                    });

            "Then the recording fake forwards calls to the wrapped service"
                .x(() => A.CallTo(() => realServiceWhileRecording.GetCount("1"))
                    .MustHaveHappened(Repeated.Exactly.Twice));

            "And the recording fake returns the wrapped service's results"
                .x(() => countsWhileRecording.Should().Equal(0x1A, 0x2, 0x1B));

            "And the playback fake does not forward calls to the wrapped service"
                .x(() => A.CallTo(realServiceDuringPlayback).MustNotHaveHappened());

            "And the playback fake returns the recorded results"
                .x(() => countsDuringPlayback.Should().Equal(0x1A, 0x2, 0x1B));
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:71,代码来源:SelfInitializedFakesSpecs.cs

示例4: SelfInitializingWithFileRecorder

        public static void SelfInitializingWithFileRecorder(
            string fileRecorderPath,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            int countWhileRecording,
            int countDuringPlayback)
        {
            "Given a path that does not exist"
                .x(() => fileRecorderPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()));

            "And a real service to wrap while recording"
                .x(() =>
                {
                    realServiceWhileRecording = A.Fake<ILibraryService>();

                    A.CallTo(() => realServiceWhileRecording.GetCount("8"))
                        .Returns(0x8);
                });

            "And a real service to wrap while playing back"
                .x(() => realServiceDuringPlayback = A.Fake<ILibraryService>());

            "When I use a self-initialized fake recording to the path to get the count for book 8"
                .x(() =>
                {
                    using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                    {
                        var fakeService = A.Fake<ILibraryService>(options => options
                            .Wrapping(realServiceWhileRecording).RecordedBy(recorder));
                        countWhileRecording = fakeService.GetCount("8");
                    }
                })
                .Teardown(() => File.Delete(fileRecorderPath));

            "And I use a self-initialized fake playing back from the path to get the count for book 8"
                .x(() =>
                {
                    using (var recorder = Recorders.FileRecorder(fileRecorderPath))
                    {
                        var playbackFakeService = A.Fake<ILibraryService>(options => options
                            .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                        countDuringPlayback = playbackFakeService.GetCount("8");
                    }
                });

            "Then the recording fake returns the wrapped service's result"
                .x(() => countWhileRecording.Should().Be(8));

            "And the playback fake returns the recorded result"
                .x(() => countDuringPlayback.Should().Be(8));
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:52,代码来源:SelfInitializedFakesSpecs.cs

示例5: SelfInitializingIgnoresParameterValues

        public static void SelfInitializingIgnoresParameterValues(
            InMemoryStorage inMemoryStorage,
            ILibraryService realServiceWhileRecording,
            ILibraryService realServiceDuringPlayback,
            IEnumerable<int> countsWhileRecording,
            IEnumerable<int> countsDuringPlayback)
        {
            "Given a call storage object"
                .x(() => inMemoryStorage = new InMemoryStorage());

            "And a real service to wrap while recording"
                .x(() =>
                {
                    realServiceWhileRecording = A.Fake<ILibraryService>();

                    A.CallTo(() => realServiceWhileRecording.GetCount("1"))
                        .Returns(0x1);
                    A.CallTo(() => realServiceWhileRecording.GetCount("2"))
                        .Returns(0x2);
                });

            "And a real service to wrap while playing back"
                .x(() => realServiceDuringPlayback = A.Fake<ILibraryService>());

            "When I use a self-initialized fake in recording mode to get the counts for book 2 and 1"
                .x(() =>
                {
                    using (var recorder = new RecordingManager(inMemoryStorage))
                    {
                        var fakeService = A.Fake<ILibraryService>(options => options
                            .Wrapping(realServiceWhileRecording).RecordedBy(recorder));

                        countsWhileRecording = new List<int>
                            {
                                fakeService.GetCount("2"),
                                fakeService.GetCount("1")
                            };
                    }
                });

            "And I use a self-initialized fake in playback mode to get the counts for book 1 and 2"
                .x(() =>
                {
                    using (var recorder = new RecordingManager(inMemoryStorage))
                    {
                        var playbackFakeService = A.Fake<ILibraryService>(options => options
                            .Wrapping(realServiceDuringPlayback).RecordedBy(recorder));

                        countsDuringPlayback = new List<int>
                            {
                                playbackFakeService.GetCount("1"),
                                playbackFakeService.GetCount("2"),
                            };
                    }
                });

            "Then the recording fake returns the wrapped service's results"
                .x(() => countsWhileRecording.Should().Equal(0x2, 0x1));

            // These results demonstrate that the self-initialized fake relies on a script
            // defined by which methods are called, without regard to the arguments
            // passed to the methods.
            "And the playback fake returns results in 'recorded order'"
                .x(() => countsDuringPlayback.Should().Equal(0x2, 0x1));
        }
开发者ID:TimLovellSmith,项目名称:FakeItEasy,代码行数:65,代码来源:SelfInitializedFakesSpecs.cs


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