예제 #1
0
        public void TestRequestCacheSubclassNoOverrides()
        {
            HystrixCommand <int> subCmd1 = new SubCommandNoOverride("cache", true);

            Assert.Equal(1, subCmd1.Execute());
            HystrixCommand <int> subCmd2 = new SubCommandNoOverride("cache", true);

            Assert.Equal(1, subCmd2.Execute());
            HystrixCommand <int> subCmd3 = new SubCommandNoOverride("no-cache", true);

            Assert.Equal(1, subCmd3.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("SubCommandNoOverride", info1.CommandKey.Name);
            Assert.Equal(1, info1.ExecutionEvents.Count);
            IHystrixInvokableInfo info2 = infos[1];

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

            Assert.Equal("SubCommandNoOverride", info3.CommandKey.Name);
            Assert.Equal(1, info3.ExecutionEvents.Count);
        }
예제 #2
0
        public void TestRequestLogSubClassNoOverrides()
        {
            HystrixCommand <int> subCmd = new SubCommandNoOverride("cache", true);

            Assert.Equal(1, subCmd.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("SubCommandNoOverride", info.CommandKey.Name);
        }
예제 #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());
        }