Beispiel #1
0
            public void should_create_string_with_seconds()
            {
                Expires expires = Expires.In(5.Seconds());

                expires.ToString().
                Should().
                Be("in 5");
            }
Beispiel #2
0
            public void should_create_expires_object_with_period()
            {
                Expires expires = Expires.In(5.Seconds());

                expires.Period.Should().
                HaveValue();
                expires.Period.Should().
                Be(5.Seconds());
                expires.Date.HasValue.Should().
                BeFalse();
            }
            public void ShouldSendOneMessageThroughTransport()
            {
                int result         = 0;
                int consumerCalled = 0;

                IBus producer = this.StartBus(
                    "producer",
                    cfg =>
                {
                    cfg.Route("dummy.request").WithDefaultCallbackEndpoint();
                    var cachingConfig = new Dictionary <string, CacheConfiguration>();
                    cachingConfig["dummy.request"] = new CacheConfiguration(true, 5.Seconds(), new MemoryCache(new Sha256Hasher(new JsonNetPayloadConverter())));
                    var cachingFilterDecorator     = new CachingFilterDecorator(cachingConfig);
                    cfg.RegisterDecoratorOf <SendingExchangeFilter>(cachingFilterDecorator);
                });

                this.StartBus(
                    "consumer",
                    cfg => cfg.On <DummyRequest>("dummy.request")
                    .ReactWith(
                        (m, ctx) =>
                {
                    consumerCalled++;
                    ctx.Reply(new DummyResponse(m.Num * 2), Expires.In(5.Seconds()));
                }));

                Enumerable.Range(1, 3)
                .ForEach(
                    _ =>
                {
                    Task <int> response = producer
                                          .RequestAsync <DummyRequest, DummyResponse>("dummy.request", new DummyRequest(13))
                                          .ContinueWith(m => result = m.Result.Num);
                    response.Wait(3.Seconds()).Should().BeTrue();
                    result.Should().Be(26);
                });

                consumerCalled.Should().Be(1);
            }
            public void ShouldSendOneMessageThroughTransport()
            {
                int result         = 0;
                int consumerCalled = 0;

                IBus producer = this.StartBus(
                    "producer",
                    cfg =>
                {
                    cfg.EnableCaching();
                    cfg.Route("dummy.request").WithDefaultCallbackEndpoint();
                });

                this.StartBus(
                    "consumer",
                    cfg => cfg.On <DummyRequest>("dummy.request")
                    .ReactWith(
                        (m, ctx) =>
                {
                    consumerCalled++;
                    ctx.Reply(new DummyResponse(m.Num * 2), Expires.In(5.Seconds()));
                }));

                Enumerable.Range(1, 3)
                .ForEach(
                    _ =>
                {
                    Task <int> response = producer
                                          .RequestAsync <DummyRequest, DummyResponse>("dummy.request", new DummyRequest(13))
                                          .ContinueWith(m => result = m.Result.Num);
                    response.Wait(3.Seconds()).Should().BeTrue();
                    result.Should().Be(26);
                });

                consumerCalled.Should().Be(1);
            }