public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<TweetQueryGenerator>();
     _fakeGeoQueryGenerator = _fakeBuilder.GetFake<IGeoQueryGenerator>();
     _fakeTweetQueryValidator = _fakeBuilder.GetFake<ITweetQueryValidator>();
     _fakeTwitterStringFormatter = _fakeBuilder.GetFake<ITwitterStringFormatter>();
 }
예제 #2
0
 public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<UserController>();
     _fakeUserQueryExecutor = _fakeBuilder.GetFake<IUserQueryExecutor>();
     _fakeTweetFactory = _fakeBuilder.GetFake<ITweetFactory>();
     _fakeUserFactory = _fakeBuilder.GetFake<IUserFactory>();
 }
        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);
        }
 public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<FriendshipQueryExecutor>();
     _fakeFriendshipQueryGenerator = _fakeBuilder.GetFake<IFriendshipQueryGenerator>();
     _fakeUserQueryValidator = _fakeBuilder.GetFake<IUserQueryValidator>();
     _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();
 }
        public void CloseServiceRequiresOpenServiceControlManager(Fake<IAdvApi32> advApi32)
        {
            var sut = new ServiceConnection(advApi32.FakedObject);

            var connectionHandle = new ConnectionHandle();

            Assert.Throws<MissingServiceManagerConnectionException>(() => sut.Close(connectionHandle));
        }
        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<FriendshipJsonController>();
            _fakeFriendshipQueryGenerator = _fakeBuilder.GetFake<IFriendshipQueryGenerator>();
            _fakeFriendshipFactory = _fakeBuilder.GetFake<IFriendshipFactory>();
            _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();

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

            _cursorQueryIds = new List<long>();
        }
예제 #8
0
 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
 }
        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();
        }
예제 #10
0
        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);
        }
        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<FriendshipQueryGenerator>();
            _fakeUserQueryParameterGenerator = _fakeBuilder.GetFake<IUserQueryParameterGenerator>();
            _fakeUserQueryValidator = _fakeBuilder.GetFake<IUserQueryValidator>();

            _fakeUserQueryParameterGenerator.ArrangeGenerateIdParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateScreenNameParameter();
            _fakeUserQueryParameterGenerator.ArrangeGenerateIdOrScreenNameParameter();
            _fakeUserQueryValidator.ArrangeIsUserIdValid();
        }
        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);
        }
예제 #13
0
 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
 }
예제 #14
0
        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();
        }
        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);
        }
예제 #16
0
        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);
        }
        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();
        }
        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);
        }
        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
        }
예제 #20
0
        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());
        }
        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
        }
예제 #22
0
        public void Index_IsRequested_ReturnsViewResult()
        {
            // Arrange
            var mockHttpContext = new Mock<HttpContextBase>();
            mockHttpContext.Setup(x => x.Request.QueryString).Returns(new NameValueCollection());
            var articles = new Fake<IArticleRepository>();
            var comments = new Fake<ICommentRepository>();
            var controller = new ArticlesController(
                articles.FakedObject, comments.FakedObject, mockHttpContext.Object);
            A.CallTo(() => controller._articleRepository.GetsArticles(A<int>.Ignored, A<int>.Ignored)).Returns(null);

            // Act
            var result = controller.Index();

            // Assert
            Assert.IsInstanceOfType(result, typeof(ViewResult));
        }
        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;
                });
        }
        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();
        }
        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);
        }
        public void FailedCloseServiceDoesNotResetConnectionHandle(Fake<IAdvApi32> advApi32, int serviceControlManagerHandleValue,
            int serviceHandleValue)
        {
            advApi32.CallsTo(_ => _.CloseService(A<IntPtr>._))
                    .Returns(false);

            var connectionHandle = new ConnectionHandle
                {
                    ServiceManagerHandle = new IntPtr(serviceControlManagerHandleValue),
                    ServiceHandle = new IntPtr(serviceHandleValue)
                };

            var sut = new ServiceConnection(advApi32.FakedObject);

            sut.Close(connectionHandle);

            var actual = connectionHandle.ServiceHandle;
            var expected = new IntPtr(serviceHandleValue);

            Assert.Equal(expected, actual);
        }
        public void ReleaseWriteLockResetsDatabaseLockHandle(Fake<IAdvApi32> advApi32, int serviceControlManagerHandlerValue,
            int serviceDatabaseLockHandleValue)
        {
            advApi32.CallsTo(_ => _.ReleaseServiceDatabaseLock(A<IntPtr>._))
                    .Returns(true);

            var sut = new ServiceDatabaseConnection(advApi32.FakedObject);

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

            sut.ReleaseLock(connectionHandle);

            var actual = connectionHandle.ServiceDatabaseLockHandle;
            var expected = IntPtr.Zero;

            Assert.Equal(expected, actual);
        }
        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);
        }
        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);
        }
        public void TestInitialize()
        {
            _fakeBuilder = new FakeClassBuilder<SearchQueryExecutor>();
            _fakeSearchQueryGenerator = _fakeBuilder.GetFake<ISearchQueryGenerator>();
            _fakeSearchQueryHelper = _fakeBuilder.GetFake<ISearchQueryHelper>();
            _fakeTwitterAccessor = _fakeBuilder.GetFake<ITwitterAccessor>();
            _fakeTweetHelper = _fakeBuilder.GetFake<ITweetHelper>();
            _fakeSearchQueryParameterGenerator = _fakeBuilder.GetFake<ISearchQueryParameterGenerator>();

            _searchQuery = TestHelper.GenerateString();
            _httpQuery = TestHelper.GenerateString();
            _statusesJson = TestHelper.GenerateString();
            _originalTweetDTO = GenerateTweetDTO(true);
            _retweetDTO = GenerateTweetDTO(false);

            _jObject = new JObject();
            _jObject["statuses"] = _statusesJson;
            _tweetDTOs = new[] { A.Fake<ITweetWithSearchMetadataDTO>() };
            _searchResultDTO = A.Fake<ISearchResultsDTO>();
            _searchResultDTO.CallsTo(x => x.TweetDTOs).Returns(_tweetDTOs);

            _tweetSearchParameter = A.Fake<ITweetSearchParameters>();
            _fakeSearchQueryParameterGenerator.CallsTo(x => x.CreateSearchTweetParameter(_searchQuery)).Returns(_tweetSearchParameter);
        }
예제 #31
0
        /// <summary>
        /// Gets a configuration object allowing for further configuration of
        /// any calll to the specified faked object.
        /// </summary>
        /// <typeparam name="TFake">The type of fake object.</typeparam>
        /// <param name="fakedObject">The faked object to configure.</param>
        /// <returns>A configuration object.</returns>
        public static IAnyCallConfiguration CallTo <TFake>(TFake fakedObject)
        {
            var configurationFactory = ServiceLocator.Current.Resolve <IStartConfigurationFactory>();

            return(configurationFactory.CreateConfiguration <TFake>(Fake.GetFakeObject(fakedObject)).AnyCall());
        }
예제 #32
0
 /// <summary>
 /// Asserts on the faked object.
 /// </summary>
 /// <returns>A fake assertions object.</returns>
 private IFakeAssertions <T> Assert()
 {
     return(ServiceLocator.Current.Resolve <IFakeAssertionsFactory>().CreateAsserter <T>(Fake.GetFakeObject(this.FakedObject)));
 }
예제 #33
0
 private static T CreateFake <T>(IEnumerable <object> argumentsForConstructor)
 {
     return((T)Fake.CreateFactory().CreateFake(typeof(T), argumentsForConstructor, false));
 }
예제 #34
0
        /// <summary>
        /// Gets an object that provides a fluent interface syntax for configuring
        /// the fake object.
        /// </summary>
        /// <typeparam name="TFake">The type of the fake object.</typeparam>
        /// <param name="fakedObject">The fake object to configure.</param>
        /// <returns>A configuration object.</returns>
        /// <exception cref="ArgumentNullException">The fakedObject was null.</exception>
        /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception>
        public static IFakeConfiguration <TFake> Configure <TFake>(TFake fakedObject) where TFake : class
        {
            Guard.IsNotNull(fakedObject, "fakedObject");

            return(new FakeConfiguration <TFake>(Fake.GetFakeObject(fakedObject)));
        }
예제 #35
0
        /// <summary>
        /// Gets all the calls made to the specified fake object.
        /// </summary>
        /// <typeparam name="TFake">The type of the faked object.</typeparam>
        /// <param name="fakedObject">The faked object.</param>
        /// <returns>A collection containing the calls to the object.</returns>
        /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception>
        public static CallCollection <TFake> GetCalls <TFake>(TFake fakedObject) where TFake : class
        {
            Guard.IsNotNull(fakedObject, "fakedObject");

            return(new CallCollection <TFake>(Fake.GetFakeObject(fakedObject)));
        }
예제 #36
0
 /// <summary>
 /// Casts the specified fake object to the specified interface type, if
 /// the fake does not already implment the interface it will be implemented.
 /// </summary>
 /// <param name="fakedObject">The faked object to cast.</param>
 /// <typeparam name="T">The type of interface to implement.</typeparam>
 /// <returns>The faked object cast to the specified interface type.</returns>
 /// <exception cref="ArgumentException">The specified type is not an interface type.</exception>
 /// <exception cref="ArgumentNullException">The interfaceType parameter is null or the fakedObject parameter is null.</exception>
 public static T CastTo <T>(object fakedObject) where T : class
 {
     Fake.CastTo(typeof(T), fakedObject);
     return((T)fakedObject);
 }
예제 #37
0
        /// <summary>
        /// Gets all the calls made to the specified fake object.
        /// </summary>
        /// <param name="fakedObject">The faked object.</param>
        /// <returns>A collection containing the calls to the object.</returns>
        /// <exception cref="ArgumentException">The object passed in is not a faked object.</exception>
        public static IEnumerable <ICompletedFakeObjectCall> GetCalls(object fakedObject)
        {
            Guard.IsNotNull(fakedObject, "fakedObject");

            return(Fake.GetFakeObject(fakedObject).RecordedCallsInScope);
        }
예제 #38
0
 /// <summary>
 /// Asserts on the faked object.
 /// </summary>
 /// <returns>A fake assertions object.</returns>
 public IFakeAssertions <T> Assert()
 {
     return(Fake.Assert(this.FakedObject));
 }
예제 #39
0
 /// <summary>
 /// Configures any call to the fake object.
 /// </summary>
 /// <returns>A configuration object.</returns>
 public IVoidConfiguration <T> AnyCall()
 {
     return(Fake.Configure(this.FakedObject).AnyCall());
 }
예제 #40
0
 /// <summary>
 /// Configures calls to the specified member.
 /// </summary>
 /// <param name="callSpecification">An expression specifying the call to configure.</param>
 /// <returns>A configuration object.</returns>
 public IVoidConfiguration <T> CallsTo(Expression <Action <T> > callSpecification)
 {
     return(Fake.Configure(this.FakedObject).CallsTo(callSpecification));
 }
예제 #41
0
 /// <summary>
 /// Configures calls to the specified member.
 /// </summary>
 /// <typeparam name="TMember">The type of value the member returns.</typeparam>
 /// <param name="callSpecification">An expression specifying the call to configure.</param>
 /// <returns>A configuration object.</returns>
 public IReturnValueConfiguration <T, TMember> CallsTo <TMember>(Expression <Func <T, TMember> > callSpecification)
 {
     return(Fake.Configure(this.FakedObject).CallsTo(callSpecification));
 }