Пример #1
0
            public void Should_not_save_time_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.Time("name", 10, "tag2=value2", "sum,count", 10, 50);

                messageBuffer.Verify((mb) => mb.Save(It.IsAny <string>()), Times.Never());
            }
Пример #2
0
            public void Should_save_time_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.Time("time", 10, null, "sum,count", 10, 50);

                messageBuffer.Verify((mb) => mb.Save(It.IsAny <string>()), Times.Once);
            }
Пример #3
0
            public void Should_save_time_message_When_message_is_within_sample_rate()
            {
                var expected      = "domain.timer.time,app=appname,tag1=value1,tag2=value2 10 1000 sum,count,10 50";
                var messageBuffer = new MessageBufferFake();

                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.Time("time", 10, "tag2=value2", "sum,count", 10, 50);

                Assert.AreEqual(expected, messageBuffer.message);
            }
Пример #4
0
            public void Should_save_time_message_when_aggregations_are_defined()
            {
                var messageBuffer = new MessageBufferFake();

                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.Time("name", 10, "tag2=value2", "avg", 10, 50);

                var expected = "domain.timer.name,app=appname,tag1=value1,tag2=value2 10 1000 avg,10 50";

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