public CommonTest() { _params = new TestParams(); _createChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _useChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _useChannelAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _closeChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _closeChannelAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _closeFactoryStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _closeFactoryAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _openChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); _openChannelAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples, _params.ExceptionHandler); // Figure out the service calls timeout value int timeoutMs = TestHelpers.SendTimeoutMs; if (timeoutMs <= 0) { // If the timeout was not set then one alternative (to just using the usual default timeout) // would be to wait for a binding to be created and then getting its timeout and only then initialize _timeoutTracker. // This involves some additional synchronization which we want to avoid here. timeoutMs = 60000; } _timeoutTracker = new OperationTimeoutTracker <ChannelType>(timeoutMs, ReportTimeout); }
static RecyclablePooledFactoriesAndChannels_OpenOnce() { // moving the following magic numbers to the test template interface will help each test to collect different type of stats s_CreateChannelStats = new CallStats(samples: 1000, errorSamples: 1000); s_CallChannelStats = new CallStats(samples: 1000000, errorSamples: 10000); s_CloseChannelStats = new CallStats(samples: 1000, errorSamples: 1000); s_CloseFactoryStats = new CallStats(samples: 1000, errorSamples: 1000); s_test = new TestTemplate(); Console.WriteLine(s_test.GetType().ToString()); // Perhaps a helper (extension?) method to hide new PoolOfThings would make things more readable s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, OpenOnceChannelWrapper <ChannelType> > >( maxSize: 3, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, OpenOnceChannelWrapper <ChannelType> >( createFactoryInstance: () => s_test.CreateChannelFactory(), destroyFactoryInstance: (chf) => s_CloseFactoryStats.CallActionAndRecordStats(() => s_test.CloseFactory(chf)), maxPooledObjects: 3, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_CreateChannelStats.CallFuncAndRecordStats(func: () => new OpenOnceChannelWrapper <ChannelType>(s_test.CreateChannel(chf))), destroyObject: (chWr) => s_CloseChannelStats.CallActionAndRecordStats(action: () => s_test.CloseChannel(chWr.Channel)) ), destroyInstance: (_fapoic) => _fapoic.Destroy())); }
// move this outside of the test - an external code should query the test for its call stats private static void PrintStats(CallStats stats, StringBuilder sb) { sb.AppendLine("Sunny:"); AppendStats(stats.SunnyDay, sb); sb.AppendLine("Rainy:"); AppendStats(stats.RainyDay, sb); }
public CommonTest() { _params = new TestParams(); _createChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); _useChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); _useChannelAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); _closeChannelStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); _closeChannelAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); _closeFactoryStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); _closeFactoryAsyncStats = new CallStats(_params.SunnyDayMaxStatsSamples, _params.RainyDayMaxStatsSamples); }