public void TestMetricsPublisherReset() { // precondition: HystrixMetricsPublisherFactory class is not loaded. Calling HystrixPlugins.reset() here should be good enough to run this with other tests. // set first custom publisher IHystrixCommandKey key = HystrixCommandKeyDefault.AsKey("key"); IHystrixMetricsPublisherCommand firstCommand = new HystrixMetricsPublisherCommandDefault(key, null, null, null, null); HystrixMetricsPublisher firstPublisher = new CustomPublisher(firstCommand); HystrixPlugins.RegisterMetricsPublisher(firstPublisher); // ensure that first custom publisher is used IHystrixMetricsPublisherCommand cmd = HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForCommand(key, null, null, null, null); Assert.True(firstCommand == cmd); // reset, then change to second custom publisher HystrixPlugins.Reset(); IHystrixMetricsPublisherCommand secondCommand = new HystrixMetricsPublisherCommandDefault(key, null, null, null, null); HystrixMetricsPublisher secondPublisher = new CustomPublisher(secondCommand); HystrixPlugins.RegisterMetricsPublisher(secondPublisher); // ensure that second custom publisher is used cmd = HystrixMetricsPublisherFactory.CreateOrRetrievePublisherForCommand(key, null, null, null, null); Assert.True(firstCommand != cmd); Assert.True(secondCommand == cmd); }
public void PassCustomToNormalEventArgsReversedRegistration() { CustomPublisher p = new CustomPublisher(); NormalSubscriber s = new NormalSubscriber(); this.testee.Register(s); this.testee.Register(p); p.Fire(); }