public void Returns_Different_Instance_For_Different_CommandIdentifier()
            {
                var factory             = new HystrixCommandFactory(defaultOptions);
                var firstHystrixCommand = factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));

                // Act
                var secondHystrixCommand = factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandY"));

                Assert.NotSame(firstHystrixCommand, secondHystrixCommand);
            }
            public void Returns_Same_Instance_For_CommandIdentifier_With_Same_GroupKey_And_CommandKey()
            {
                var factory             = new HystrixCommandFactory(defaultOptions);
                var firstHystrixCommand = factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));

                // Act
                var secondHystrixCommand = factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));

                Assert.Same(firstHystrixCommand, secondHystrixCommand);
            }
Esempio n. 3
0
            public async Task Writes_Command_Json_For_All_HystrixCommands_To_OutputStream()
            {
                HystrixCommandFactory commandFactory = new HystrixCommandFactory(new HystrixOptions());
                int pollingInterval = 1000;
                var endpoint        = new HystrixMetricsStreamEndpoint(commandFactory, pollingInterval);

                commandFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));
                commandFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandY"));

                // Act
                await endpoint.WriteAllCommandsJsonToOutputStream(new MemoryStream(), CancellationToken.None);
            }
            public void Returns_List_With_All_Previously_Created_HystrixCommands()
            {
                var factory = new HystrixCommandFactory(defaultOptions);

                factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));
                factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandY"));

                // Act
                IEnumerable <IHystrixCommand> list = factory.GetAllHystrixCommands();

                Assert.Equal(2, list.Count());
            }
            public async Task Writes_Command_Json_For_All_HystrixCommands_To_OutputStream()
            {
                HystrixCommandFactory commandFactory = new HystrixCommandFactory();
                int pollingInterval = 1000;
                var endpoint        = new HystrixMetricsStreamEndpoint(commandFactory, pollingInterval);

                commandFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));
                commandFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandY"));
                var httpResponseMock = new Mock <HttpResponseBase>();

                httpResponseMock.Setup(x => x.OutputStream).Returns(new MemoryStream());

                // act
                await endpoint.WriteAllCommandsJsonToOutputStream(httpResponseMock.Object);
            }
            public void Returns_Instance_Of_Type_IHystrixCommand()
            {
                var factory = new HystrixCommandFactory(defaultOptions);

                // Act
                var hystrixCommand = factory.GetHystrixCommand("groupA", "commandX");

                Assert.NotNull(hystrixCommand);
                Assert.IsType <HystrixCommand>(hystrixCommand);
            }
            public void Returns_Instance_Of_Type_IHystrixCommand()
            {
                var factory = new HystrixCommandFactory();

                // act
                var hystrixCommand = factory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));

                Assert.NotNull(hystrixCommand);
                Assert.IsType <HystrixCommand>(hystrixCommand);
            }
            public void Returns_Same_Instance_For_CommandIdentifier_With_Same_GroupKey_And_CommandKey_From_Different_Factories()
            {
                var firstFactory        = new HystrixCommandFactory();
                var firstHystrixCommand = firstFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));
                var secondFactory       = new HystrixCommandFactory();

                // act
                var secondHystrixCommand = secondFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));

                Assert.Same(firstHystrixCommand, secondHystrixCommand);
            }
            public async Task Returns_Json_String_In_Hystrix_Format_For_HystrixCommand()
            {
                HystrixCommandFactory commandFactory = new HystrixCommandFactory();
                int pollingInterval = 1000;
                var endpoint        = new HystrixMetricsStreamEndpoint(commandFactory, pollingInterval);
                var hystrixCommand  = commandFactory.GetHystrixCommand(new HystrixCommandIdentifier("groupA", "commandX"));

                // act
                var commandJson = await endpoint.GetCommandJson(hystrixCommand);

                Assert.NotNull(commandJson);
            }
            //[Fact]
            public void LoadTest()
            {
                IHystrixCommandFactory factory = new HystrixCommandFactory(defaultOptions);

                Stopwatch stopwatch = Stopwatch.StartNew();

                for (int i = 0; i < 100000; i++)
                {
                    var hystrixCommand = factory.GetHystrixCommand("group", "key" + (i % 10));
                }

                stopwatch.Stop();
                Assert.Equal(50, stopwatch.Elapsed.Milliseconds); // 540, 114
            }