• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# FakeItEasy.Fake类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中FakeItEasy.Fake的典型用法代码示例。如果您正苦于以下问题:C# Fake类的具体用法?C# Fake怎么用?C# Fake使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Fake类属于FakeItEasy命名空间,在下文中一共展示了Fake类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TestInitialize

 public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<UserController>();
     _fakeUserQueryExecutor = _fakeBuilder.GetFake<IUserQueryExecutor>();
     _fakeTweetFactory = _fakeBuilder.GetFake<ITweetFactory>();
     _fakeUserFactory = _fakeBuilder.GetFake<IUserFactory>();
 }
开发者ID:Murtaza-libs,项目名称:tweetinvi,代码行数:7,代码来源:UserControllerTests.cs


示例2: TestInitialize

 public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<FriendshipQueryExecutor>();
     _fakeFriendshipQueryGenerator = _fakeBuilder.GetFake<IFriendshipQueryGenerator>();
     _fakeUserQueryValidator = _fakeBuilder.GetFake<IUserQueryValidator>();
     _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();
 }
开发者ID:SowaLabs,项目名称:Tweetinvi-obsolete,代码行数:7,代码来源:FriendshipQueryExecutorTests.cs


示例3: TestInitialize

 public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<TweetQueryGenerator>();
     _fakeGeoQueryGenerator = _fakeBuilder.GetFake<IGeoQueryGenerator>();
     _fakeTweetQueryValidator = _fakeBuilder.GetFake<ITweetQueryValidator>();
     _fakeTwitterStringFormatter = _fakeBuilder.GetFake<ITwitterStringFormatter>();
 }
开发者ID:Murtaza-libs,项目名称:tweetinvi,代码行数:7,代码来源:TweetQueryGeneratorTests.cs


示例4: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<RateLimitCacheManager>();
            _fakeRateLimitCache = _fakeBuilder.GetFake<IRateLimitCache>();
            _fakeRateLimitHelper = _fakeBuilder.GetFake<IRateLimitHelper>();
            _fakeTwitterRequester = _fakeBuilder.GetFake<ITwitterRequester>();
            _fakeHelpQueryGenerator = _fakeBuilder.GetFake<IHelpQueryGenerator>();
            _fakeJsonObjectConverter = _fakeBuilder.GetFake<IJsonObjectConverter>();
            _fakeCredentialsAccessor = _fakeBuilder.GetFake<ICredentialsAccessor>();
            _fakeTwitterQueryFactory = _fakeBuilder.GetFake<ITwitterQueryFactory>();

            InitializeData();

            _fakeRateLimitHelper.CallsTo(x => x.GetEndpointRateLimitFromQuery(TEST_QUERY, _credentialsRateLimits)).Returns(_endpointRateLimit);
            _fakeRateLimitCache.CallsTo(x => x.GetCredentialsRateLimits(_credentials)).Returns(_credentialsRateLimits);

            _fakeRateLimitCache.CallsTo(x => x.RefreshEntry(_credentials, _credentialsRateLimits)).Invokes(() =>
            {
                _fakeRateLimitCache.CallsTo(x => x.GetCredentialsRateLimits(_credentials)).Returns(_refreshedCredentialsRateLimits);
                _fakeRateLimitHelper.CallsTo(x => x.GetEndpointRateLimitFromQuery(TEST_QUERY, _refreshedCredentialsRateLimits)).Returns(_refreshedEndpointRateLimit);
            });

            _fakeCredentialsAccessor.SetupPassThrough<ICredentialsRateLimits>();

            _fakeHelpQueryGenerator.CallsTo(x => x.GetCredentialsLimitsQuery()).Returns(TEST_QUERY);

            _fakeTwitterRequester.CallsTo(x => x.ExecuteQuery(_twitterQuery, null)).Returns(TEST_QUERY);
            _fakeJsonObjectConverter.CallsTo(x => x.DeserializeObject<ICredentialsRateLimits>(TEST_QUERY, It.IsAny<JsonConverter[]>())).ReturnsNextFromSequence(_credentialsRateLimits, _credentialsRateLimits2);

            _fakeTwitterQueryFactory.CallsTo(x => x.Create(TEST_QUERY, It.IsAny<HttpMethod>(), It.IsAny<ITwitterCredentials>())).Returns(_twitterQuery);
        }
开发者ID:SowaLabs,项目名称:TweetinviNew,代码行数:31,代码来源:RateLimitCacheManagerTests.cs


示例5: CloseServiceRequiresOpenServiceControlManager

        public void CloseServiceRequiresOpenServiceControlManager(Fake<IAdvApi32> advApi32)
        {
            var sut = new ServiceConnection(advApi32.FakedObject);

            var connectionHandle = new ConnectionHandle();

            Assert.Throws<MissingServiceManagerConnectionException>(() => sut.Close(connectionHandle));
        }
开发者ID:SleddogSoftwareDevelopment,项目名称:ExtendedTrail,代码行数:8,代码来源:ServiceConnectionTests.cs


示例6: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<FriendshipJsonController>();
            _fakeFriendshipQueryGenerator = _fakeBuilder.GetFake<IFriendshipQueryGenerator>();
            _fakeFriendshipFactory = _fakeBuilder.GetFake<IFriendshipFactory>();
            _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();

            ArrangeFriendshipFactoryAuthorizations();
        }
开发者ID:SowaLabs,项目名称:Tweetinvi-obsolete,代码行数:9,代码来源:FriendshipJsonControllerTests.cs


示例7: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<UserQueryExecutor>();
            _fakeUserQueryGenerator = _fakeBuilder.GetFake<IUserQueryGenerator>();
            _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();
            _fakeWebHelper = _fakeBuilder.GetFake<IWebHelper>();

            _cursorQueryIds = new List<long>();
        }
开发者ID:SowaLabs,项目名称:Tweetinvi-obsolete,代码行数:9,代码来源:UserQueryExecutorTests.cs


示例8: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<FriendshipQueryGenerator>();
            _fakeUserQueryParameterGenerator = _fakeBuilder.GetFake<IUserQueryParameterGenerator>();
            _fakeUserQueryValidator = _fakeBuilder.GetFake<IUserQueryValidator>();

            _fakeUserQueryParameterGenerator.ArrangeGenerateIdParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateIdOrScreenNameParameter();
            _fakeUserQueryValidator.ArrangeIsUserIdValid();
        }
开发者ID:SowaLabs,项目名称:TweetinviNew,代码行数:11,代码来源:FriendshipQueryGeneratorTests.cs


示例9: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<MessageQueryGenerator>();
            _fakeMessageQueryValidator = _fakeBuilder.GetFake<IMessageQueryValidator>();
            _fakeUserQueryParameterGenerator = _fakeBuilder.GetFake<IUserQueryParameterGenerator>();
            _fakeUserQueryValidator = _fakeBuilder.GetFake<IUserQueryValidator>();
            _fakeTwitterStringFormatter = _fakeBuilder.GetFake<ITwitterStringFormatter>();

            _fakeUserQueryParameterGenerator.ArrangeGenerateIdParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter();
        }
开发者ID:Murtaza-libs,项目名称:tweetinvi,代码行数:11,代码来源:MessageQueryGeneratorTests.cs


示例10: SpecificationIsCorrectWhenInitializedWithSpecification

 public void SpecificationIsCorrectWhenInitializedWithSpecification()
 {
     // Fixture setup
     var expected = new Fake<IRequestSpecification>().FakedObject;
     var sut = new FakeItEasyRelay(expected);
     // Exercise system
     IRequestSpecification result = sut.FakeableSpecification;
     // Verify outcome
     Assert.Equal(expected, result);
     // Teardown
 }
开发者ID:jpierson,项目名称:AutoFixture,代码行数:11,代码来源:FakeItEasyRelayTest.cs


示例11: UsesFallbackWhenIsSet

        public void UsesFallbackWhenIsSet()
        {
            const string someid = "SomeId";
            var mock = new Fake<ILocalizationService>();
            mock.CallsTo(loc => loc.GetString(IdSrvConstants.Messages, someid)).Returns("fallbackValue");
            
            var service = new GlobalizedLocalizationService(new LocaleOptions{ Locale = "nb-NO", FallbackLocalizationService = mock.FakedObject});

            var result = service.GetString(IdSrvConstants.Messages, someid);
            Assert.Equal("fallbackValue", result);
        }
开发者ID:ryanmar,项目名称:IdentityServer3.Contrib.Localization,代码行数:11,代码来源:TheService.cs


示例12: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<RateLimitUpdater>();
            _fakeRateLimitCacheManager = _fakeBuilder.GetFake<IRateLimitCacheManager>();
            _fakeCredentialsAccessor = _fakeBuilder.GetFake<ICredentialsAccessor>();

            InitializeData();

            _fakeRateLimitCacheManager.CallsTo(x => x.GetQueryRateLimit(TEST_QUERY, _credentials)).Returns(_endpointRateLimit);
            _fakeCredentialsAccessor.CallsTo(x => x.CurrentThreadCredentials).Returns(_credentials);
        }
开发者ID:SowaLabs,项目名称:TweetinviNew,代码行数:11,代码来源:RateLimitUpdaterTests.cs


示例13: CreateWithNonAbstractionRequestReturnsCorrectResult

 public void CreateWithNonAbstractionRequestReturnsCorrectResult(object request)
 {
     // Fixture setup
     var sut = new FakeItEasyRelay();
     var dummyContext = new Fake<ISpecimenContext>().FakedObject;
     // Exercise system
     var result = sut.Create(request, dummyContext);
     // Verify outcome
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
开发者ID:jpierson,项目名称:AutoFixture,代码行数:12,代码来源:FakeItEasyRelayTest.cs


示例14: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<LoggedUser>();
            _fakeCredentialsAccessor = _fakeBuilder.GetFake<ICredentialsAccessor>();
            _fakeTimelineController = _fakeBuilder.GetFake<ITimelineController>();
            _fakeFriendshipController = _fakeBuilder.GetFake<IFriendshipController>();
            _fakeSavedSearchController = _fakeBuilder.GetFake<ISavedSearchController>();
            _fakeMessageController = _fakeBuilder.GetFake<IMessageController>();
            _fakeTweetController = _fakeBuilder.GetFake<ITweetController>();
            _fakeAccountController = _fakeBuilder.GetFake<IAccountController>();

            InitData();
        }
开发者ID:SowaLabs,项目名称:Tweetinvi-obsolete,代码行数:13,代码来源:LoggedUserTests.cs


示例15: OpenServiceManagerGetsCorrectConnectionHandle

        public void OpenServiceManagerGetsCorrectConnectionHandle(Fake<IAdvApi32> advApi32, long pointerValue)
        {
            advApi32.CallsTo(_ => _.OpenServiceControlManager(A<string>._, A<string>._, A<ScmAccess>._))
                    .Returns(new IntPtr(pointerValue));

            var sut = new ServiceDatabaseConnection(advApi32.FakedObject);

            var connectionHandle = sut.Open();

            var actual = connectionHandle.ServiceManagerHandle;
            var expected = new IntPtr(pointerValue);

            Assert.Equal(expected, actual);
        }
开发者ID:SleddogSoftwareDevelopment,项目名称:ExtendedTrail,代码行数:14,代码来源:ServiceDatabaseConnectionTests.cs


示例16: ReleaseWriteLockCallsUnderlyingAPI

        public void ReleaseWriteLockCallsUnderlyingAPI(Fake<IAdvApi32> advApi32, int serviceControlManagerHandlerValue,
            int serviceDatabaseLockHandleValue)
        {
            var sut = new ServiceDatabaseConnection(advApi32.FakedObject);

            var connectionHandle = new ConnectionHandle
                {
                    ServiceManagerHandle = new IntPtr(serviceControlManagerHandlerValue),
                    ServiceDatabaseLockHandle = new IntPtr(serviceDatabaseLockHandleValue)
                };

            sut.ReleaseLock(connectionHandle);

            advApi32.CallsTo(_ => _.ReleaseServiceDatabaseLock(A<IntPtr>._)).MustHaveHappened();
        }
开发者ID:SleddogSoftwareDevelopment,项目名称:ExtendedTrail,代码行数:15,代码来源:ServiceDatabaseConnectionTests.cs


示例17: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<RateLimitAwaiter>();
            _fakeRateLimitCacheManager = _fakeBuilder.GetFake<IRateLimitCacheManager>();
            _fakeCredentialsAccessor = _fakeBuilder.GetFake<ICredentialsAccessor>();
            _fakeThreadHelper = _fakeBuilder.GetFake<IThreadHelper>();

            _credentials = A.Fake<ITwitterCredentials>();
            _endpointRateLimit = A.Fake<IEndpointRateLimit>();
            _endpointRateLimit.CallsTo(x => x.Remaining).Returns(0);
            _endpointRateLimit.CallsTo(x => x.ResetDateTimeInMilliseconds).Returns(TIME_TO_WAIT);

            _fakeRateLimitCacheManager.CallsTo(x => x.GetQueryRateLimit(TEST_QUERY, _credentials)).Returns(_endpointRateLimit);
            _fakeCredentialsAccessor.CallsTo(x => x.CurrentThreadCredentials).Returns(_credentials);
        }
开发者ID:SowaLabs,项目名称:TweetinviNew,代码行数:15,代码来源:RateLimitAwaiterTests.cs


示例18: CreateWithFakeRequestReturnsCorrectResult

        public void CreateWithFakeRequestReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(Fake<object>);
            var context = new Fake<ISpecimenContext>().FakedObject;

            var builderStub = new Fake<ISpecimenBuilder>();
            builderStub.CallsTo(b => b.Create(request, context)).Returns(new Fake<object>());

            var sut = new FakeItEasyBuilder(builderStub.FakedObject);
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.IsAssignableFrom<Fake<object>>(result);
            // Teardown
        }
开发者ID:AutoFixture,项目名称:AutoFixture,代码行数:16,代码来源:FakeItEasyBuilderTest.cs


示例19: TestInitialize

        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<TweetQueryExecutor>();
            _fakeTweetQueryGenerator = _fakeBuilder.GetFake<ITweetQueryGenerator>();
            _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();

            var fakeWebExceptionInfoExtractor = A.Fake<IWebExceptionInfoExtractor>();

            var twitter139ExceptionInfos = new TwitterExceptionInfo { Code = 139 };
            fakeWebExceptionInfoExtractor.CallsTo(x => x.GetTwitterExceptionInfo(It.IsAny<WebException>())).Returns(new [] { twitter139ExceptionInfos });
            _fake139TwitterException = new TwitterException(fakeWebExceptionInfoExtractor, new WebException(), TestHelper.GenerateString());

            var twitterOtherExceptionInfos = new TwitterExceptionInfo { Code = 1 };
            fakeWebExceptionInfoExtractor.CallsTo(x => x.GetTwitterExceptionInfo(It.IsAny<WebException>())).Returns(new[] { twitterOtherExceptionInfos });
            _fakeOtherTwitterException = new TwitterException(fakeWebExceptionInfoExtractor, new WebException(), TestHelper.GenerateString());
        }
开发者ID:rudiv,项目名称:tweetinvi,代码行数:16,代码来源:TweetQueryExecutorTests.cs


示例20: CustomizeAddsAppropriateCustomizations

        public void CustomizeAddsAppropriateCustomizations()
        {
            // Fixture setup
            var customizations = new List<ISpecimenBuilder>();
            var fixtureStub = new Fake<IFixture>();
            fixtureStub.CallsTo(c => c.Customizations).Returns(customizations);

            var sut = new AutoFakeItEasyCustomization();
            // Exercise system
            sut.Customize(fixtureStub.FakedObject);
            // Verify outcome
            var postprocessor = customizations.OfType<FakeItEasyBuilder>().Single();
            var ctorInvoker = Assert.IsAssignableFrom<MethodInvoker>(postprocessor.Builder);
            Assert.IsAssignableFrom<FakeItEasyMethodQuery>(ctorInvoker.Query);
            // Teardown
        }
开发者ID:RyanLiu99,项目名称:AutoFixture,代码行数:16,代码来源:AutoFakeItEasyCustomizationTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# FakeXrmEasy.XrmFakedContext类代码示例发布时间:2022-05-26
下一篇:
C# Alapfunkciok.Tablainfo类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap