public void TestStreamHasData()
        {
            AtomicBoolean  commandShowsUp    = new AtomicBoolean(false);
            AtomicBoolean  threadPoolShowsUp = new AtomicBoolean(false);
            CountdownEvent latch             = new CountdownEvent(1);
            int            NUM = 10;

            for (int i = 0; i < 2; i++)
            {
                HystrixCommand <int> cmd = Command.From(groupKey, commandKey, HystrixEventType.SUCCESS, 50);
                cmd.Observe();
            }

            stream.Observe().Take(NUM).Subscribe(
                (utilization) =>
            {
                output.WriteLine(DateTime.Now.Ticks / 10000 + " : Received data with : " + " : Received data with : " + utilization.CommandUtilizationMap.Count + " commands");
                if (utilization.CommandUtilizationMap.ContainsKey(commandKey))
                {
                    commandShowsUp.Value = true;
                }
                if (utilization.ThreadPoolUtilizationMap.Count != 0)
                {
                    threadPoolShowsUp.Value = true;
                }
            },
                (e) =>
            {
                output.WriteLine(DateTime.Now.Ticks / 10000 + " : " + Thread.CurrentThread.ManagedThreadId + " OnError : " + e);
                latch.SignalEx();
            },
                () =>
            {
                output.WriteLine(DateTime.Now.Ticks / 10000 + " : " + Thread.CurrentThread.ManagedThreadId + " OnCompleted");
                latch.SignalEx();
            });


            Assert.True(latch.Wait(10000));
            Assert.True(commandShowsUp.Value);
            Assert.True(threadPoolShowsUp.Value);
        }
        public void TestStreamHasData()
        {
            var commandShowsUp    = new AtomicBoolean(false);
            var threadPoolShowsUp = new AtomicBoolean(false);
            var latch             = new CountdownEvent(1);
            var num = 10;

            for (var i = 0; i < 2; i++)
            {
                HystrixCommand <int> cmd = Command.From(GroupKey, CommandKey, HystrixEventType.SUCCESS, 50);
                cmd.Observe();
            }

            stream.Observe().Take(num).Subscribe(
                (utilization) =>
            {
                output.WriteLine(Time.CurrentTimeMillis + " : Received data with : " + " : Received data with : " + utilization.CommandUtilizationMap.Count + " commands");
                if (utilization.CommandUtilizationMap.ContainsKey(CommandKey))
                {
                    commandShowsUp.Value = true;
                }

                if (utilization.ThreadPoolUtilizationMap.Count != 0)
                {
                    threadPoolShowsUp.Value = true;
                }
            },
                (e) =>
            {
                output.WriteLine(Time.CurrentTimeMillis + " : " + Thread.CurrentThread.ManagedThreadId + " OnError : " + e);
                latch.SignalEx();
            },
                () =>
            {
                output.WriteLine(Time.CurrentTimeMillis + " : " + Thread.CurrentThread.ManagedThreadId + " OnCompleted");
                latch.SignalEx();
            });

            Assert.True(latch.Wait(10000), "CountdownEvent was not set!");
            Assert.True(commandShowsUp.Value);
            Assert.True(threadPoolShowsUp.Value);
        }
 public HystrixUtilizationStreamController(HystrixUtilizationStream stream)
     : this(stream.Observe())
 {
 }