Exemplo n.º 1
0
            public void Should_save_counter_message_when_tags_are_not_defined()
            {
                var messageBuffer = new Mock <IMessageBuffer>();

                this.luckyCoin.Setup((lc) => lc.Throw(It.IsAny <int>())).Returns(true);
                this.timestamp.Setup((ts) => ts.Now()).Returns(1000);
                var client = new StatfulClient(this.configurationGateway, messageBuffer.Object, this.timestamp.Object, this.luckyCoin.Object);

                client.Inc("inc", 10, null, "sum,count", 10, 50);

                messageBuffer.Verify((mb) => mb.Save(It.IsAny <string>()), Times.Once);
            }
Exemplo n.º 2
0
            public void Should_not_save_counter_message_When_message_is_out_sample_rate()
            {
                var messageBuffer = new Mock <IMessageBuffer>();

                this.luckyCoin.Setup((lc) => lc.Throw(It.IsAny <int>())).Returns(false);
                this.timestamp.Setup((ts) => ts.Now()).Returns(1000);
                var client = new StatfulClient(this.configurationGateway, messageBuffer.Object, this.timestamp.Object, this.luckyCoin.Object);

                client.Inc("inc", 10, "tag2=value2", "sum,count", 10, 50);

                messageBuffer.Verify((mb) => mb.Save(It.IsAny <string>()), Times.Never);
            }
Exemplo n.º 3
0
            public void Should_save_counter_message_When_message_is_within_sample_rate()
            {
                var messageBuffer = new MessageBufferFake();
                var expected      = "domain.counter.inc,app=appname,tag1=value1,tag2=value2 10 1000 sum,count,10 50";

                this.luckyCoin.Setup((lc) => lc.Throw(It.IsAny <int>())).Returns(true);
                this.timestamp.Setup((ts) => ts.Now()).Returns(1000);
                var client = new StatfulClient(this.configurationGateway, messageBuffer, this.timestamp.Object, this.luckyCoin.Object);

                client.Inc("inc", 10, "tag2=value2", "sum,count", 10, 50);

                Assert.AreEqual(expected, messageBuffer.message);
            }