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


C# TestHandler类代码示例

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


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

示例1: setup

        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler<ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler = new TestHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = GivenProjectionStateHandler();
            _firstWriteCorrelationId = Guid.NewGuid();
            _workerId = Guid.NewGuid();
            var dispatcher = new ProjectionManagerMessageDispatcher(new Dictionary<Guid, IPublisher>{{_workerId, GetInputQueue()}});
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig = GivenProjectionConfig();
            var projectionProcessingStrategy = GivenProjectionProcessingStrategy();
            _coreProjection = GivenCoreProjection(projectionProcessingStrategy);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe(new AdHocHandler<ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler<ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            _bus.Subscribe<PartitionProcessingResultOutputBase>(dispatcher);
            PreWhen();
            When();
        }
开发者ID:czcz1024,项目名称:EventStore,代码行数:27,代码来源:TestFixtureWithCoreProjection.cs

示例2: setup

        public void setup()
        {
            _subscribeProjectionHandler = new TestHandler<ReaderSubscriptionManagement.Subscribe>();
            _writeEventHandler = new TestHandler<ClientMessage.WriteEvents>();
            _bus.Subscribe(_subscribeProjectionHandler);
            _bus.Subscribe(_writeEventHandler);


            _stateHandler = _stateHandler
                            ?? new FakeProjectionStateHandler(configureBuilder: _configureBuilderByQuerySource);
            _firstWriteCorrelationId = Guid.NewGuid();
            _projectionCorrelationId = Guid.NewGuid();
            _projectionConfig = new ProjectionConfig(null, 
                _checkpointHandledThreshold, _checkpointUnhandledBytesThreshold, 1000, 250, true, true,
                _createTempStreams, _stopOnEof);
            _coreProjection = CoreProjection.CreateAndPrepare(
                "projection", _version, _projectionCorrelationId, _bus, _stateHandler, _projectionConfig, _readDispatcher,
                _writeDispatcher, _subscriptionDispatcher, null, _timeProvider);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointCompleted>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.CheckpointLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.PrerecordedEventsLoaded>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.RestartRequested>(_coreProjection);
            _bus.Subscribe<CoreProjectionProcessingMessage.Failed>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.CommittedEventReceived>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.CheckpointSuggested>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.EofReached>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.ProgressChanged>(_coreProjection);
            _bus.Subscribe<EventReaderSubscriptionMessage.NotAuthorized>(_coreProjection);
            _bus.Subscribe(new AdHocHandler<ProjectionCoreServiceMessage.CoreTick>(tick => tick.Action()));
            _bus.Subscribe(new AdHocHandler<ReaderCoreServiceMessage.ReaderTick>(tick => tick.Action()));
            PreWhen();
            When();
        }
开发者ID:jjvdangelo,项目名称:EventStore,代码行数:33,代码来源:TestFixtureWithCoreProjection.cs

示例3: DelegateTest

 static void DelegateTest()
 {
     TestHandler th = new TestHandler(DoSomething);
     th += new TestHandler(DoSomething);
     th += new TestHandler(DoSomething);
     th();
 }
开发者ID:NoMad28,项目名称:HelloWorld_TC,代码行数:7,代码来源:Program.cs

示例4: handlers_after_publishing_message_all_is_still_done_correctly

        public void handlers_after_publishing_message_all_is_still_done_correctly()
        {
            var handler1 = new TestHandler<TestMessage>();
            var handler2 = new TestHandler<TestMessage>();
            var handler3 = new TestHandler<TestMessage>();

            _bus.Subscribe<TestMessage>(handler1);
            _bus.Subscribe<TestMessage>(handler2);
            _bus.Subscribe<TestMessage>(handler3);

            _bus.Publish(new TestMessage());
            handler1.HandledMessages.Clear();
            handler2.HandledMessages.Clear();
            handler3.HandledMessages.Clear();

            //just to ensure
            Assert.That(handler1.HandledMessages.ContainsNo<TestMessage>() &&
                        handler2.HandledMessages.ContainsNo<TestMessage>() &&
                        handler3.HandledMessages.ContainsNo<TestMessage>());

            _bus.Unsubscribe(handler1);
            _bus.Unsubscribe(handler2);
            _bus.Unsubscribe(handler3);
            _bus.Publish(new TestMessage());

            Assert.That(handler1.HandledMessages.ContainsNo<TestMessage>() &&
                        handler2.HandledMessages.ContainsNo<TestMessage>() &&
                        handler3.HandledMessages.ContainsNo<TestMessage>());
        }
开发者ID:robashton,项目名称:EventStore,代码行数:29,代码来源:when_unsubscribing_from_memory_bus.cs

示例5: Main

 static void Main()
 {
     System.Console.WriteLine("Testing...");
     TestHandler t = new TestHandler();
     FunctionServer f = new FunctionServer(t);
     f.Run();
 }
开发者ID:mnar53,项目名称:xlloop,代码行数:7,代码来源:ServerExample.cs

示例6: StartTest

 public static void StartTest(string testName, TestHandler initCode, TestHandler loadCode, TestHandler updateCode, TestHandler drawCode)
 {
     using (TestGame game = new TestGame(testName,initCode,loadCode,updateCode,drawCode))
     {
         game.Run();
     }
 }
开发者ID:elefantstudio-se,项目名称:survivaldf,代码行数:7,代码来源:TestGame.cs

示例7: Setup

 public void Setup()
 {
     _consumer = new TestHandler<Message>();
     _bus = new InMemoryBus("temp");
     _bus.Subscribe(_consumer);
     ICheckpoint writerCheckpoint = new InMemoryCheckpoint(1000);
     var ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus));
     _readerService = new EventReaderCoreService(_bus, ioDispatcher, 10, writerCheckpoint, runHeadingReader: true);
     _subscriptionDispatcher =
         new ReaderSubscriptionDispatcher(_bus);
     _spoolProcessingResponseDispatcher = new SpooledStreamReadingDispatcher(_bus);
     _timeoutScheduler = new TimeoutScheduler();
     _workerId = Guid.NewGuid();
     _service = new ProjectionCoreService(
         _workerId, _bus, _bus, _subscriptionDispatcher, new RealTimeProvider(), ioDispatcher,
         _spoolProcessingResponseDispatcher, _timeoutScheduler);
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionEofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionMeasured>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionDeleted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());
     _bus.Subscribe(_spoolProcessingResponseDispatcher.CreateSubscriber<PartitionProcessingResult>());
     _readerService.Handle(new Messages.ReaderCoreServiceMessage.StartReader());
     _service.Handle(new ProjectionCoreServiceMessage.StartCore());
 }
开发者ID:czcz1024,项目名称:EventStore,代码行数:30,代码来源:TestFixtureWithProjectionCoreService.cs

示例8: VerifyExistanceOfExplicitUserAgent

        public void VerifyExistanceOfExplicitUserAgent()
        {
            var customAgent = new List<ProductInfoHeaderValue>() { new ProductInfoHeaderValue("TEST", "123") };

            var testHandler = new TestHandler(
                                  (request, cancelation) =>
                                  {
                                      // Ensure User-Agent is sent
                                      Assert.That(request.Headers.UserAgent, Is.Not.Null.Or.Empty);
                                      Assert.That(request.Headers.UserAgent.Count, Is.EqualTo(2));

                                      Assert.That(request.Headers.UserAgent, Has.Exactly(1).Matches<ProductInfoHeaderValue>(a => a.Product.Name == "TEST"));

                                      return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
                                  });

            var clientWrapper = new HttpClientWrapper(customAgent, _versionHandler, _authorizationHandlerhandler, testHandler);

            var client = clientWrapper.HttpClient;

            // ReSharper disable once MethodSupportsCancellation
            var response = client.GetAsync("http://lodididki");

            Assert.AreEqual(HttpStatusCode.OK, response.Result.StatusCode);
        }
开发者ID:JudoPay,项目名称:DotNetSDK,代码行数:25,代码来源:HeaderChainAdded.cs

示例9: AuthorizeWithBasicAuthentication

        public void AuthorizeWithBasicAuthentication()
        {
            var logger = Substitute.For<ILog>();
            var testHandler = new TestHandler((request, cancelation) =>
            {
                Assert.AreEqual("Basic",
                    request.Headers.Authorization.Scheme);
                var authDetailsBytes = Convert.FromBase64String(request.Headers.Authorization.Parameter);
                var authDetails = Encoding.GetEncoding("iso-8859-1").GetString(authDetailsBytes);

                var authArray = authDetails.Split(':');

                Assert.AreEqual("testToken", authArray[0]);
                Assert.AreEqual("testSecret", authArray[1]);

                return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
            });
            var credentials = new Credentials("testToken", "testSecret");

            var handler = new AuthorizationHandler(credentials, logger) {InnerHandler = testHandler};

            var client = new HttpClient(handler);

            // ReSharper disable once MethodSupportsCancellation
            var response = client.GetAsync("http://lodididki");

            Assert.AreEqual(HttpStatusCode.OK, response.Result.StatusCode);
        }
开发者ID:JudoPay,项目名称:DotNetSDK,代码行数:28,代码来源:AuthorizationHandlerTests.cs

示例10: setup

        public void setup()
        {
            _checkpointUnhandledBytesThreshold = 1000;
            _checkpointProcessedEventsThreshold = 2000;
            Given();
            _bus = new InMemoryBus("bus");
            _projectionCorrelationId = Guid.NewGuid();
            _eventHandler = new TestHandler<EventReaderSubscriptionMessage.CommittedEventReceived>();
            _checkpointHandler = new TestHandler<EventReaderSubscriptionMessage.CheckpointSuggested>();
            _progressHandler = new TestHandler<EventReaderSubscriptionMessage.ProgressChanged>();
            _subscriptionStartedHandler = new TestHandler<EventReaderSubscriptionMessage.SubscriptionStarted>();
            _notAuthorizedHandler = new TestHandler<EventReaderSubscriptionMessage.NotAuthorized>();
            _eofHandler = new TestHandler<EventReaderSubscriptionMessage.EofReached>();
            _partitionEofHandler = new TestHandler<EventReaderSubscriptionMessage.PartitionEofReached>();
            _partitionMeasuredHandler = new TestHandler<EventReaderSubscriptionMessage.PartitionMeasured>();

            _bus.Subscribe(_eventHandler);
            _bus.Subscribe(_checkpointHandler);
            _bus.Subscribe(_progressHandler);
            _bus.Subscribe(_eofHandler);
            _bus.Subscribe(_partitionEofHandler);
            _bus.Subscribe(_partitionMeasuredHandler);
            _readerStrategy = CreateCheckpointStrategy();
            _subscription = CreateProjectionSubscription();


            When();
        }
开发者ID:msbahrul,项目名称:EventStore,代码行数:28,代码来源:TestFixtureWithProjectionSubscription.cs

示例11: VersionHeaderTest

        public void VersionHeaderTest()
        {
            const string versionHeaderValue = "3.2";

            var testHandler = new TestHandler(
                                  (request, cancelation) =>
                                      {
                                          var requestVersionHeader = request.Headers.FirstOrDefault(h => h.Key == VersioningHandler.API_VERSION_HEADER);

                                          Assert.IsNotNull(requestVersionHeader);
                                          Assert.That(requestVersionHeader.Value.FirstOrDefault(), Is.Not.Null.Or.Empty);
                                          Assert.That(requestVersionHeader.Value.FirstOrDefault(), Is.EqualTo(versionHeaderValue));

                                          return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
                                      });

            var handler = new VersioningHandler(versionHeaderValue) { InnerHandler = testHandler };

            var client = new HttpClient(handler);

            // ReSharper disable once MethodSupportsCancellation
            var response = client.GetAsync("http://lodididki");

            Assert.AreEqual(HttpStatusCode.OK, response.Result.StatusCode);
        }
开发者ID:JudoPay,项目名称:DotNetSDK,代码行数:25,代码来源:VersioningTests.cs

示例12: setup

 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestHandler<ClientMessage.ReadStreamEventsBackward>();
     _bus.Subscribe(_listEventsHandler);
     _ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus));
     _subscriptionDispatcher =
         new ReaderSubscriptionDispatcher
             (_bus);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionEofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.PartitionMeasured>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.SubscriptionStarted>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ReaderAssignedReader>());
     _bus.Subscribe(_ioDispatcher.BackwardReader);
     _bus.Subscribe(_ioDispatcher.ForwardReader);
     _bus.Subscribe(_ioDispatcher.Writer);
     _bus.Subscribe(_ioDispatcher);
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     _projectionConfig = new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false, false);
     var version = new ProjectionVersion(1, 0, 0);
     var projectionProcessingStrategy = new ContinuousProjectionProcessingStrategy(
         "projection", version, projectionStateHandler, _projectionConfig,
         projectionStateHandler.GetSourceDefinition(), null, _subscriptionDispatcher);
     _coreProjection = projectionProcessingStrategy.Create(
         Guid.NewGuid(), _bus, SystemAccount.Principal, _bus, _ioDispatcher, _subscriptionDispatcher,
         new RealTimeProvider());
     _coreProjection.Start();
 }
开发者ID:msbahrul,项目名称:EventStore,代码行数:35,代码来源:when_starting_a_projection.cs

示例13: setup

 public void setup()
 {
     _bus = new InMemoryBus("bus");
     _listEventsHandler = new TestHandler<ClientMessage.ReadStreamEventsBackward>();
     _bus.Subscribe(_listEventsHandler);
     _readDispatcher = new RequestResponseDispatcher
         <ClientMessage.ReadStreamEventsBackward, ClientMessage.ReadStreamEventsBackwardCompleted>(
         _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus));
     _writeDispatcher = new RequestResponseDispatcher<ClientMessage.WriteEvents, ClientMessage.WriteEventsCompleted>(
         _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus));
     _subscriptionDispatcher =
         new PublishSubscribeDispatcher
             <ReaderSubscriptionManagement.Subscribe,
                 ReaderSubscriptionManagement.ReaderSubscriptionManagementMessage, EventReaderSubscriptionMessage>
             (_bus, v => v.SubscriptionId, v => v.SubscriptionId);
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CommittedEventReceived>());
     _bus.Subscribe(
         _subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.CheckpointSuggested>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.EofReached>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.ProgressChanged>());
     _bus.Subscribe(_subscriptionDispatcher.CreateSubscriber<EventReaderSubscriptionMessage.NotAuthorized>());
     _bus.Subscribe(_readDispatcher);
     _bus.Subscribe(_writeDispatcher);
     IProjectionStateHandler projectionStateHandler = new FakeProjectionStateHandler();
     _projectionConfig = new ProjectionConfig(null, 5, 10, 1000, 250, true, true, false, false);
     _coreProjection = CoreProjection.CreateAndPrepare(
         "projection", new ProjectionVersion(1, 0, 0), Guid.NewGuid(), _bus, projectionStateHandler, _projectionConfig, _readDispatcher,
         _writeDispatcher, _subscriptionDispatcher, null, new RealTimeProvider());
     _coreProjection.Start();
 }
开发者ID:jjvdangelo,项目名称:EventStore,代码行数:31,代码来源:when_starting_a_projection.cs

示例14: TestSecurityMessageHandler

                public TestSecurityMessageHandler(
                    bool isAllowed,
                    HttpResponseMessage responseMessage)
                {
                    IsAllowed = isAllowed;

                    InnerHandler = new TestHandler(responseMessage);
                }
开发者ID:c4rm4x,项目名称:C4rm4x.WebApi,代码行数:8,代码来源:SecurityMessageHandlerTest.SendAsync.cs

示例15: Skip_waiting_when_call_performed

        public void Skip_waiting_when_call_performed()
        {
            var handler = new TestHandler<int>();

            handler.Handle(10);

            Assert.DoesNotThrow(() => handler.WaitUntilCalled());
        }
开发者ID:Codestellation,项目名称:Emisstar,代码行数:8,代码来源:TestHandlerTests.cs


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