public async Task When_a_html_report_is_opened()
        {
            _driver = await _driverHandle.ObtainAsync();

            Driver.Navigate().GoToUrl(HtmlFileName);
            Driver.EnsurePageIsLoaded();
        }
Exemple #2
0
        private Task RunTasks(ResourcePool <IDisposable> pool, int count)
        {
            async Task RunTask()
            {
                using (var provider = new ResourceHandle <IDisposable>(pool))
                {
                    await Task.Yield();

                    await provider.ObtainAsync();

                    await Task.Delay(250);
                }
            }

            return(RunTasks(count, RunTask));
        }
Exemple #3
0
        public void Given_resource_can_be_used_only_by_one_provider_at_a_time()
        {
            var holder = new InstanceHolder();
            var usage  = new ConcurrentDictionary <object, object>();

            ResourcePool <IDisposable> pool;

            async Task RunTask()
            {
                using (var provider = new ResourceHandle <IDisposable>(pool))
                {
                    var instance = await provider.ObtainAsync();

                    usage.AddOrUpdate(instance, instance, (_, __) => throw new InvalidOperationException("Instance already in use!"));
                    await Task.Delay(250);

                    usage.TryRemove(instance, out _);
                }
            }

            using (pool = new ResourcePool <IDisposable>(holder.CreateInstance, 5))
                Assert.DoesNotThrowAsync(() => RunTasks(5, RunTask));
        }
Exemple #4
0
 public async Task ResourceHandle_should_return_the_same_instance()
 {
     using (var pool = new ResourcePool <IDisposable>(new InstanceHolder().CreateInstance))
         using (var handle = new ResourceHandle <IDisposable>(pool))
             Assert.That(await handle.ObtainAsync(), Is.SameAs(await handle.ObtainAsync()));
 }