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())); }
static RecyclablePooledFactoriesAndChannelsAsync_OpenOnce() { s_test = new TestTemplate(); // It is expected to see various exceptions when we use factories while recycling them (s_test as IExceptionPolicy).RelaxedExceptionPolicy = true; s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings < FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, OpenAsyncOnceChannelWrapper <ChannelType> > >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: () => new FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, OpenAsyncOnceChannelWrapper <ChannelType> >( createFactoryInstance: s_test.CreateChannelFactory, destroyFactoryInstanceAsync: async(chf) => await s_test.CloseFactoryAsync(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, createObject: (chf) => { var channel = s_test.CreateChannel(chf); // If channel creation failed and is unexpected we'd already catch it inside s_test.CreateChannel. // If the failure is expected then we will get null back. // In this case we simply return null instead of wrapping it and let the pool handle it return(channel != null ? new OpenAsyncOnceChannelWrapper <ChannelType>(channel) : null); }, destroyObjectAsync: async(chWr) => await s_test.CloseChannelAsync(chWr.Channel), validateObjectInstance: (oaocw) => s_test.ValidateChannel(oaocw.Channel)), destroyInstanceAsync: async(fapoio) => await fapoio.DestroyAsync(), instanceValidator: (fapoio) => s_test.ValidateFactory(fapoio.Factory))); }
static PooledFactoriesAsync() { s_test = new TestTemplate(); s_pooledChannelFactories = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings <ChannelFactory <ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: () => s_test.CreateChannelFactory(), destroyInstanceAsync: async(chf) => await s_test.CloseFactoryAsync(chf))); }
static PooledFactories() { s_test = new TestTemplate(); s_pooledChannelFactories = StaticDisposablesHelper.AddDisposable( new PoolOfThings <ChannelFactory <ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: () => s_test.CreateChannelFactory(), destroyInstance: (chf) => s_test.CloseFactory(chf), instanceValidator: s_test.ValidateFactory)); }
static PooledFactories() { s_test = new TestTemplate(); s_pooledChannelFactories = StaticDisposablesHelper.AddDisposable( new PoolOfThings <ChannelFactory <ChannelType> >( maxSize: 10, createInstance: () => s_test.CreateChannelFactory(), destroyInstance: (chf) => s_CloseFactoryStats.CallActionAndRecordStats(() => s_test.CloseFactory(chf)))); }
static RecyclablePooledFactoriesAsync() { s_test = new TestTemplate(); // It is expected to see various exceptions when we use factories while recycling them (s_test as IExceptionPolicy).RelaxedExceptionPolicy = true; s_recyclablePooledChannelFactories = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings <ChannelFactory <ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: s_test.CreateChannelFactory, destroyInstanceAsync: async(chf) => await s_test.CloseFactoryAsync(chf))); }
static PooledFactoriesAsync() { s_test = new TestTemplate(); // we do not expect exceptions here since we're not closing anything during usage (s_test as IExceptionPolicy).RelaxedExceptionPolicy = false; s_pooledChannelFactories = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings <ChannelFactory <ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: () => s_test.CreateChannelFactory(), destroyInstanceAsync: async(chf) => await s_test.CloseFactoryAsync(chf), instanceValidator: s_test.ValidateFactory)); }
static RecyclablePooledFactoriesAndChannels_OpenOnce() { s_test = new TestTemplate(); // It is expected to see various exceptions when we use factories while recycling them (s_test as IExceptionPolicy).RelaxedExceptionPolicy = true; s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, OpenOnceChannelWrapper <ChannelType> > >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, OpenOnceChannelWrapper <ChannelType> >( createFactoryInstance: () => s_test.CreateChannelFactory(), destroyFactoryInstance: (chf) => s_test.CloseFactory(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, createObject: (chf) => new OpenOnceChannelWrapper <ChannelType>(s_test.CreateChannel(chf)), destroyObject: (chWr) => s_test.CloseChannel(chWr.Channel)), destroyInstance: (_fapoio) => _fapoio.Destroy())); }
static PooledFactoriesAndChannelsAsync() { s_test = new TestTemplate(); s_pooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings <FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: s_test.CreateChannelFactory, destroyFactoryInstanceAsync: async(chf) => await s_test.CloseFactoryAsync(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_test.CreateChannel(chf), destroyObjectAsync: async(ch) => await s_test.CloseChannelAsync(ch) ), destroyInstanceAsync: async(_fapoiao) => await _fapoiao.DestroyAsync())); }
static PooledFactoriesAndChannels() { s_test = new TestTemplate(); s_pooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: 3, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, 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(s_test.CreateChannel, chf), destroyObject: (ch) => s_CloseChannelStats.CallActionAndRecordStats(() => s_test.CloseChannel(ch)) ), destroyInstance: (_fapoic) => _fapoic.Destroy())); }
static RecyclablePooledFactoriesAndChannelsAsync_OpenOnce() { s_test = new TestTemplate(); s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings < FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, OpenAsyncOnceChannelWrapper <ChannelType> > >( maxSize: 3, // # of pooled FactoryAndPoolOfItsChannels createInstance: () => new FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, OpenAsyncOnceChannelWrapper <ChannelType> >( createFactoryInstance: s_test.CreateChannelFactory, destroyFactoryInstanceAsync: async(chf) => await s_CloseFactoryStats.CallAsyncFuncAndRecordStatsAsync(s_test.CloseFactoryAsync, chf), maxPooledObjects: 3, // # of pooled channels within each pooled FactoryAndPoolOfItsAsyncObjects createObject: (chf) => s_CreateChannelStats.CallFuncAndRecordStats(func: () => new OpenAsyncOnceChannelWrapper <ChannelType>(s_test.CreateChannel(chf))), destroyObjectAsync: async(chWr) => await s_CloseChannelStats.CallAsyncFuncAndRecordStatsAsync(func: () => s_test.CloseChannelAsync(chWr.Channel)) ), destroyInstanceAsync: async(_fapoic) => await _fapoic.DestroyAsync())); }
static PooledFactoriesAndChannels() { s_test = new TestTemplate(); s_pooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: s_test.CreateChannelFactory, destroyFactoryInstance: (chf) => s_test.CloseFactory(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_test.CreateChannel(chf), destroyObject: (ch) => s_test.CloseChannel(ch), validateObjectInstance: s_test.ValidateChannel), destroyInstance: (fapoio) => fapoio.Destroy(), instanceValidator: (fapoiao) => s_test.ValidateFactory(fapoiao.Factory))); }
static RecyclablePooledFactoriesAndChannelsAsync() { s_test = new TestTemplate(); // It is expected to see various exceptions when we use factories while recycling them (s_test as IExceptionPolicy).RelaxedExceptionPolicy = true; s_recyclablePooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfAsyncThings <FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, createInstance: () => new FactoryAndPoolOfItsAsyncObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: () => s_test.CreateChannelFactory(), destroyFactoryInstanceAsync: async(chf) => await s_test.CloseFactoryAsync(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, createObject: (chf) => s_test.CreateChannel(chf), destroyObjectAsync: (ch) => s_test.CloseChannelAsync(ch), validateObjectInstance: s_test.ValidateChannel), destroyInstanceAsync: (fapoio) => fapoio.DestroyAsync(), instanceValidator: (fapoio) => s_test.ValidateFactory(fapoio.Factory))); }
static PooledFactoriesAndChannels() { s_test = new TestTemplate(); // we do not expect exceptions here since we're not closing anything during usage (s_test as IExceptionPolicy).RelaxedExceptionPolicy = false; s_pooledFactoriesAndChannels = StaticDisposablesHelper.AddDisposable( new PoolOfThings <FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType> >( maxSize: s_test.TestParameters.MaxPooledFactories, // # of pooled FactoryAndPoolOfItsObjects createInstance: () => new FactoryAndPoolOfItsObjects <ChannelFactory <ChannelType>, ChannelType>( createFactoryInstance: s_test.CreateChannelFactory, destroyFactoryInstance: (chf) => s_test.CloseFactory(chf), maxPooledObjects: s_test.TestParameters.MaxPooledChannels, // # of pooled channels within each pooled FactoryAndPoolOfItsObjects createObject: (chf) => s_test.CreateChannel(chf), destroyObject: (ch) => s_test.CloseChannel(ch), validateObjectInstance: s_test.ValidateChannel), destroyInstance: (fapoio) => fapoio.Destroy(), instanceValidator: (fapoiao) => s_test.ValidateFactory(fapoiao.Factory))); }
public TestTemplateWrap(ITestEpisodeViewModel episodeViewModel, ITestTemplate testTemplate) { _episodeViewModel = episodeViewModel; _testTemplate = testTemplate; }
static CreateAndCloseFactoryAndChannelFullCycleTestAsync() { s_test = new TestTemplate(); // we do not expect exceptions here since we're not closing anything during usage (s_test as IExceptionPolicy).RelaxedExceptionPolicy = false; }
static CreateAndCloseFactoryAndChannelFullCycleTest() { s_test = new TestTemplate(); }