Ejemplo n.º 1
0
            public void send_timer_with_lamba_and_sampleRate_passes()
            {
                const string statName = "name";

                var stopwatch = MockRepository.GenerateMock <IStopwatch>();

                stopwatch.Stub(x => x.ElapsedMilliseconds()).Return(500);
                _stopwatch.Stub(x => x.Get()).Return(stopwatch);
                _randomGenerator = MockRepository.GenerateMock <IRandomGenerator>();
                _randomGenerator.Stub(x => x.ShouldSend(Arg <double> .Is.Anything)).Return(true);

                var s = new Statsd(new Statsd.Configuration()
                {
                    Udp = _udp, RandomGenerator = _randomGenerator, StopwatchFactory = _stopwatch, Sender = _sender
                });

                s.Send(() => TestMethod(), statName, 0.1);

                IList <object[]> argsPerCall = _sender.GetArgumentsForCallsMadeOn(x => x.Send(Arg <Metric> .Is.Anything));

                Assert.That(argsPerCall.Count, Is.EqualTo(1));
                Assert.That(((Metric)argsPerCall[0][0]).Command, Is.EqualTo("name:500|ms"));
            }
 public void Setup()
 {
     _udp = MockRepository.GenerateMock <IStatsdUDP>();
 }