Ejemplo n.º 1
0
        public void Should_Publish_Events_Within_Batch()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator  = new NoArgEventTranslator();
            var translators = new[] { translator, translator, translator };

            ringBuffer.PublishEvents(translators, 1, 2);
            Assert.True(ringBuffer.TryPublishEvents(translators, 1, 2));

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(
                            new object[1] {
                0L
            },
                            new object[1] {
                1L
            },
                            new object[1] {
                2L
            },
                            new object[1] {
                3L
            }));
        }
Ejemplo n.º 2
0
        public void Should_Publish_Events_Var_Arg_Within_Batch()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator = new VarArgEventTranslator();

            ringBuffer.PublishEvents(
                translator, 1, 2, new[] { "Foo0", "Bar0", "Baz0", "Bam0" },
                new[] { "Foo1", "Bar1", "Baz1", "Bam1" },
                new[] { "Foo2", "Bar2", "Baz2", "Bam2" });
            Assert.True(
                ringBuffer.TryPublishEvents(
                    translator, 1, 2, new[] { "Foo3", "Bar3", "Baz3", "Bam3" },
                    new[] { "Foo4", "Bar4", "Baz4", "Bam4" },
                    new[] { "Foo5", "Bar5", "Baz5", "Bam5" }));

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(new object[1] {
                "Foo1Bar1Baz1Bam1-0"
            }, new object[1] {
                "Foo2Bar2Baz2Bam2-1"
            }, new object[1] {
                "Foo4Bar4Baz4Bam4-2"
            }, new object[1] {
                "Foo5Bar5Baz5Bam5-3"
            }));
        }
Ejemplo n.º 3
0
        public void Should_Publish_Event_Var_Arg()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator = new VarArgEventTranslator();

            ringBuffer.PublishEvent(translator, "Arg0");
            ringBuffer.TryPublishEvent(translator, "Arg0", "Arg1");
            ringBuffer.PublishEvent(translator, "Arg0", "Arg1", "Arg2");
            ringBuffer.TryPublishEvent(translator, "Arg0", "Arg1", "Arg2", "Arg3");

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(
                            new object[1] {
                "Arg0-0"
            },
                            new object[1] {
                "Arg0Arg1-1"
            },
                            new object[1] {
                "Arg0Arg1Arg2-2"
            },
                            new object[1] {
                "Arg0Arg1Arg2Arg3-3"
            }));
        }
Ejemplo n.º 4
0
        public void Should_Publish_Events_One_Arg_Batch_Size_Of_One()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator = new OneArgEventTranslator();

            ringBuffer.PublishEvents(translator, 0, 1, new[] { "Boo" });
            Assert.True(ringBuffer.TryPublishEvents(translator, 0, 1, new[] { "Boo" }));

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(new object[1] {
                "Boo-0"
            }, new object[1] {
                "Boo-1"
            }));
        }
Ejemplo n.º 5
0
        public void Should_Publish_Event_One_Arg()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator = new OneArgEventTranslator();

            ringBuffer.PublishEvent(translator, "Arg");
            ringBuffer.TryPublishEvent(translator, "Arg");

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(new object[1] {
                "Arg-0"
            }, new object[1] {
                "Arg-1"
            }));
        }
Ejemplo n.º 6
0
        public void Should_Publish_Events_Var_Arg_Batch_Size_Of_One()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator = new VarArgEventTranslator();

            ringBuffer.PublishEvents(
                translator, 0, 1, new[] { "Foo", "Bar", "Baz", "Bam" }, new[] { "Foo1", "Bar1", "Baz1", "Bam1" });
            Assert.True(

                ringBuffer.TryPublishEvents(
                    translator, 0, 1, new[] { "Foo", "Bar", "Baz", "Bam" }, new[] { "Foo2", "Bar2", "Baz2", "Bam2" }));

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(new object[1] {
                "FooBarBazBam-0"
            }, new object[1] {
                "FooBarBazBam-1"
            }));
        }
Ejemplo n.º 7
0
        public void Should_Publish_Events_Two_Arg()
        {
            var ringBuffer = RingBuffer <object[]> .CreateSingleProducer(new ArrayFactory(1), 4);

            var translator = new TwoArgEventTranslator();

            ringBuffer.PublishEvents(translator, new[] { "Foo", "Hoo" }, new[] { "Bar", "Car" });
            Assert.True(ringBuffer.TryPublishEvents(translator, new[] { "Foo", "Hoo" }, new[] { "Bar", "Car" }));

            var matcher = new RingBufferEventMatcher(ringBuffer);

            Assert.True(matcher.RingBufferWithEvents(new object[1] {
                "FooBar-0"
            }, new object[1] {
                "HooCar-1"
            }, new object[1] {
                "FooBar-2"
            }, new object[1] {
                "HooCar-3"
            }));
        }