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 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 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);
        }
        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<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 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);
        }
        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 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);
        }
        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
        }
        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
        }
        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 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<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);
        }
Exemplo n.º 18
0
 public void TestInitialize()
 {
     _fakeBuilder = new FakeClassBuilder<WebHelper>();
     _fakeTweetinviSettingsAccessor = _fakeBuilder.GetFake<ITweetinviSettingsAccessor>();
     _fakeTweetinviSettingsAccessor.CallsTo(x => x.HttpRequestTimeout).Returns(10000);
 }
 public void CustomizeAddsAppropriateResidueCollector()
 {
     // Fixture setup
     var residueCollectors = new List<ISpecimenBuilder>();
     var fixtureStub = new Fake<IFixture>();
     fixtureStub.CallsTo(c => c.ResidueCollectors).Returns(residueCollectors);
     
     var sut = new AutoFakeItEasyCustomization();
     // Exercise system
     sut.Customize(fixtureStub.FakedObject);
     // Verify outcome
     Assert.Contains(sut.Relay, residueCollectors);
     // Teardown
 }
Exemplo n.º 20
0
        public void CreateFromFakeRequestWhenDecoratedBuilderReturnsNoFakeReturnsCorrectResult(object request, object innerResult)
        {
            // Fixture setup
            var context = new Fake<ISpecimenContext>().FakedObject;

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

            var sut = new FakeItEasyBuilder(builderStub.FakedObject);
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void OpenServiceCallsUnderlyingApi(Fake<IAdvApi32> advApi32, int serviceControlManagerHandleValue, int serviceHandleValue,
            string serviceName)
        {
            advApi32.CallsTo(_ => _.OpenService(A<IntPtr>._, A<string>._, A<ScmAccess>._))
                    .Returns(new IntPtr(serviceHandleValue));

            var sut = new ServiceConnection(advApi32.FakedObject);

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

            sut.Open(connectionHandle, serviceName);

            advApi32.CallsTo(_ => _.OpenService(A<IntPtr>._, A<string>._, A<ScmAccess>._)).MustHaveHappened();
        }
        public void OpenServiceSetsConnectionHandleToNotIntPtrZero(Fake<IAdvApi32> advApi32, int serviceControlManagerHandleValue,
            int serviceHandleValue, string serviceName)
        {
            advApi32.CallsTo(_ => _.OpenService(A<IntPtr>._, A<string>._, A<ScmAccess>._))
                    .Returns(new IntPtr(serviceHandleValue));

            var sut = new ServiceConnection(advApi32.FakedObject);

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

            sut.Open(connectionHandle, serviceName);

            var actual = connectionHandle.ServiceHandle;

            var expected = new IntPtr(serviceHandleValue);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 23
0
        public void CreateWithAbstractionRequestReturnsCorrectResult(Type request)
        {
            // Fixture setup
            var fakeType = typeof(Fake<>).MakeGenericType(request);

            var fake = Activator.CreateInstance(fakeType);
            var contextStub = new Fake<ISpecimenContext>();
            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(fake);

            var sut = new FakeItEasyRelay();
            // Exercise system
            var result = sut.Create(request, contextStub.FakedObject);
            // Verify outcome
            var expected = fake.GetType().GetProperty("FakedObject").GetValue(fake, null);
            Assert.Equal(expected, result);
            // Teardown
        }
Exemplo n.º 24
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonFake()
        {
            // Fixture setup
            var request = typeof(IInterface);
            var fakeType = typeof(Fake<>).MakeGenericType(request);

            var contextStub = new Fake<ISpecimenContext>();
            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(new object());

            var sut = new FakeItEasyRelay();
            // Exercise system
            var result = sut.Create(request, contextStub.FakedObject);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);
            Assert.Equal(expectedResult, result);
            // Teardown
        }
 public void CreateWithFakeRequestReturnsCorrectResultWhenContextReturnsNonFake(Type request, object contextValue)
 {
     // Fixture setup
     var context = new Fake<ISpecimenContext>().FakedObject;
     var builderStub = new Fake<ISpecimenBuilder>();
     builderStub.CallsTo(b => b.Create(request, context))
         .Returns(contextValue);
     var sut = new FakeItEasyBuilder(builderStub.FakedObject);
     // Exercise system
     var result = sut.Create(request, context);
     // Verify outcome
     var expectedResult = new NoSpecimen();
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void CreateFromFakeRequestWhenDecoratedBuilderReturnsFakeOfWrongGenericTypeReturnsCorrectResult()
        {
            // Fixture setup
            var request = typeof(Fake<IInterface>);
            var context = new Fake<ISpecimenContext>().FakedObject;

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

            var sut = new FakeItEasyBuilder(builderStub.FakedObject);
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var expectedResult = new NoSpecimen();
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        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);
        }