本文整理汇总了C#中FakeItEasy.Fake.CallsTo方法的典型用法代码示例。如果您正苦于以下问题:C# Fake.CallsTo方法的具体用法?C# Fake.CallsTo怎么用?C# Fake.CallsTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FakeItEasy.Fake
的用法示例。
在下文中一共展示了Fake.CallsTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: CloseServiceCallsUnderlyingApi
public void CloseServiceCallsUnderlyingApi(Fake<IAdvApi32> advApi32, int serviceControlManagerHandleValue, int serviceHandleValue)
{
advApi32.CallsTo(_ => _.CloseService(A<IntPtr>._))
.Returns(true);
var connectionHandle = new ConnectionHandle
{
ServiceManagerHandle = new IntPtr(serviceControlManagerHandleValue),
ServiceHandle = new IntPtr(serviceHandleValue)
};
var sut = new ServiceConnection(advApi32.FakedObject);
sut.Close(connectionHandle);
advApi32.CallsTo(_ => _.CloseService(A<IntPtr>._)).MustHaveHappened();
}
示例3: TestInitialize
public void TestInitialize()
{
_fakeBuilder = new FakeClassBuilder<TimelineController>();
_fakeTweetFactory = _fakeBuilder.GetFake<ITweetFactory>();
_fakeUserFactory = _fakeBuilder.GetFake<IUserFactory>();
_fakeTimelineQueryExecutor = _fakeBuilder.GetFake<ITimelineQueryExecutor>();
_fakeTimelineQueryParameterGenerator = _fakeBuilder.GetFake<ITimelineQueryParameterGenerator>();
InitData();
_fakeUserFactory.CallsTo(x => x.GenerateUserIdentifierFromScreenName(_userName)).Returns(_fakeUserIdentifier);
_fakeUserFactory.CallsTo(x => x.GenerateUserIdentifierFromId(_userId)).Returns(_fakeUserIdentifier);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateUserTimelineQueryParameters(_fakeUser, _fakeUserTimelineParameters)).Returns(_fakeUserTimelineQueryParameters);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateUserTimelineQueryParameters(_fakeUserIdentifier, _fakeUserTimelineParameters)).Returns(_fakeUserTimelineQueryParameters);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateUserTimelineParameters()).Returns(_fakeUserTimelineParameters);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateMentionsTimelineParameters()).Returns(_fakeMentionsTimelineParameters);
}
示例4: 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);
}
示例5: 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);
}
示例6: TestInitialize
public void TestInitialize()
{
_fakeBuilder = new FakeClassBuilder<TimelineJsonController>();
_fakeTimelineQueryGenerator = _fakeBuilder.GetFake<ITimelineQueryGenerator>();
_fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();
_fakeUserFactory = _fakeBuilder.GetFake<IUserFactory>();
_fakeTimelineQueryParameterGenerator = _fakeBuilder.GetFake<ITimelineQueryParameterGenerator>();
InitData();
_fakeTwitterAccessor.CallsTo(x => x.ExecuteJsonGETQuery(_expectedQuery)).Returns(_expectedResult);
_fakeUserFactory.CallsTo(x => x.GenerateUserIdentifierFromScreenName(_userName)).Returns(_fakeUserIdentifier);
_fakeUserFactory.CallsTo(x => x.GenerateUserIdentifierFromId(_userId)).Returns(_fakeUserIdentifier);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateUserTimelineQueryParameters(It.IsAny<IUserIdentifier>(), It.IsAny<IUserTimelineParameters>()))
.Returns(_fakeUserTimelineQueryParameters);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateHomeTimelineParameters()).Returns(_fakeHomeTimelineParameters);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateUserTimelineParameters()).Returns(_fakeUserTimelineParameters);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.CreateMentionsTimelineParameters()).Returns(_fakeMentionsTimelineParameters);
}
示例7: TestInitialize
public void TestInitialize()
{
_fakeBuilder = new FakeClassBuilder<TimelineQueryGenerator>();
_fakeUserQueryParameterGenerator = _fakeBuilder.GetFake<IUserQueryParameterGenerator>();
_fakeQueryParameterGenerator = _fakeBuilder.GetFake<IQueryParameterGenerator>();
_fakeUserQueryValidator = _fakeBuilder.GetFake<IUserQueryValidator>();
_fakeTimelineQueryParameterGenerator = _fakeBuilder.GetFake<ITimelineQueryParameterGenerator>();
Init();
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.GenerateExcludeRepliesParameter(It.IsAny<bool>())).Returns(_excludeRepliesParameter);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.GenerateIncludeContributorDetailsParameter(It.IsAny<bool>())).Returns(_includeContributorDetailsParameter);
_fakeUserQueryParameterGenerator.CallsTo(x => x.GenerateIdOrScreenNameParameter(_fakeUserIdentifier, "user_id", "screen_name")).Returns(_userIdentifierParameter);
_fakeTimelineQueryParameterGenerator.CallsTo(x => x.GenerateIncludeRTSParameter(It.IsAny<bool>())).Returns(_includeRTSParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateCountParameter(_maximumNumberOfTweetsParameterValue)).Returns(_maximumNumberOfTweetsParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateTrimUserParameter(It.IsAny<bool>())).Returns(_trimUserParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateSinceIdParameter(It.IsAny<long>())).Returns(_sinceIdParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateMaxIdParameter(It.IsAny<long>())).Returns(_maxIdParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateIncludeEntitiesParameter(It.IsAny<bool>())).Returns(_includeDetailsParameter);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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();
}
示例11: TestInitialize
public void TestInitialize()
{
_fakeBuilder = new FakeClassBuilder<SearchQueryGenerator>();
_fakeSearchQueryValidator = _fakeBuilder.GetFake<ISearchQueryValidator>();
_fakeSearchQueryParameterGenerator = _fakeBuilder.GetFake<ISearchQueryParameterGenerator>();
_fakeQueryParameterGenerator = _fakeBuilder.GetFake<IQueryParameterGenerator>();
InitData();
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateSearchQueryParameter(_searchQuery)).Returns(_searchQueryParameter);
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateSearchTypeParameter(_searchResultType)).Returns(_searchTypeParameter);
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateSinceParameter(_since)).Returns(_sinceParameter);
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateUntilParameter(_until)).Returns(_untilParameter);
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateLocaleParameter(_locale)).Returns(_localeParameter);
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateLangParameter(_lang)).Returns(_languageParameter);
_fakeSearchQueryParameterGenerator.CallsTo(x => x.GenerateGeoCodeParameter(_geoCode)).Returns(_geoCodeParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateCountParameter(_maximumNumberOfResults)).Returns(_maximumNumberOfResultsParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateSinceIdParameter(_sinceId)).Returns(_sinceIdParameter);
_fakeQueryParameterGenerator.CallsTo(x => x.GenerateMaxIdParameter(_maxId)).Returns(_maxIdParameter);
_fakeSearchQueryValidator.CallsTo(x => x.IsSearchParameterValid(It.IsAny<ITweetSearchParameters>())).Returns(true);
_fakeSearchQueryValidator.CallsTo(x => x.IsSearchTweetsQueryValid(It.IsAny<string>())).Returns(true);
}
示例12: 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
}
示例13: CloseServiceManagerResetsConnectionHandleToIntPtrZero
public void CloseServiceManagerResetsConnectionHandleToIntPtrZero(Fake<IAdvApi32> advApi32, int serviceManagerHandleValue)
{
advApi32.CallsTo(_ => _.CloseServiceControlManager(A<IntPtr>._))
.Returns(true);
var sut = new ServiceDatabaseConnection(advApi32.FakedObject);
var connectionHandle = new ConnectionHandle {ServiceManagerHandle = new IntPtr(serviceManagerHandleValue)};
sut.Close(connectionHandle);
var actual = connectionHandle.ServiceManagerHandle;
var expected = IntPtr.Zero;
Assert.Equal(expected, actual);
}
示例14: 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
}
示例15: TestInitialize
public void TestInitialize()
{
_fakeBuilder = new FakeClassBuilder<FriendshipController>();
_fakeFriendshipQueryExecutor = _fakeBuilder.GetFake<IFriendshipQueryExecutor>();
_fakeUserFactory = _fakeBuilder.GetFake<IUserFactory>();
_fakeFriendshipFactory = _fakeBuilder.GetFake<IFriendshipFactory>();
_fakeFriendshipFactory
.CallsTo(x => x.GenerateFriendshipAuthorizations(A<bool>.Ignored, A<bool>.Ignored))
.ReturnsLazily((bool retweets, bool notification) =>
{
var fakeAuthorization = A.Fake<IFriendshipAuthorizations>();
fakeAuthorization.RetweetsEnabled = retweets;
fakeAuthorization.DeviceNotificationEnabled = notification;
return fakeAuthorization;
});
}