Example #1
0
        public void TestRequestCacheSuperClass()
        {
            HystrixCommand <int> superCmd1 = new SuperCommand("cache", true);

            Assert.Equal(1, superCmd1.Execute());
            HystrixCommand <int> superCmd2 = new SuperCommand("cache", true);

            Assert.Equal(1, superCmd2.Execute());
            HystrixCommand <int> superCmd3 = new SuperCommand("no-cache", true);

            Assert.Equal(1, superCmd3.Execute());
            output.WriteLine("REQ LOG : " + HystrixRequestLog.CurrentRequestLog.GetExecutedCommandsAsString());
            HystrixRequestLog reqLog = HystrixRequestLog.CurrentRequestLog;

            Assert.Equal(3, reqLog.AllExecutedCommands.Count);
            List <IHystrixInvokableInfo> infos = new List <IHystrixInvokableInfo>(reqLog.AllExecutedCommands);
            IHystrixInvokableInfo        info1 = infos[0];

            Assert.Equal("SuperCommand", info1.CommandKey.Name);
            Assert.Equal(1, info1.ExecutionEvents.Count);
            IHystrixInvokableInfo info2 = infos[1];

            Assert.Equal("SuperCommand", info2.CommandKey.Name);
            Assert.Equal(2, info2.ExecutionEvents.Count);
            Assert.Equal(HystrixEventType.RESPONSE_FROM_CACHE, info2.ExecutionEvents[1]);
            IHystrixInvokableInfo info3 = infos[2];

            Assert.Equal("SuperCommand", info3.CommandKey.Name);
            Assert.Equal(1, info3.ExecutionEvents.Count);
        }
Example #2
0
        public void TestRequestLogSuperClass()
        {
            HystrixCommand <int> superCmd = new SuperCommand("cache", true);

            Assert.Equal(1, superCmd.Execute());
            output.WriteLine("REQ LOG : " + HystrixRequestLog.CurrentRequestLog.GetExecutedCommandsAsString());
            HystrixRequestLog reqLog = HystrixRequestLog.CurrentRequestLog;

            Assert.Equal(1, reqLog.AllExecutedCommands.Count);
            IHystrixInvokableInfo info = reqLog.AllExecutedCommands.ToList()[0];

            Assert.Equal("SuperCommand", info.CommandKey.Name);
        }
Example #3
0
        public void TestFallback()
        {
            HystrixCommand <int> superCmd = new SuperCommand("cache", false);

            Assert.Equal(2, superCmd.Execute());

            HystrixCommand <int> subNoOverridesCmd = new SubCommandNoOverride("cache", false);

            Assert.Equal(2, subNoOverridesCmd.Execute());

            HystrixCommand <int> subOverriddenFallbackCmd = new SubCommandOverrideFallback("cache", false);

            Assert.Equal(3, subOverriddenFallbackCmd.Execute());
        }