Beispiel #1
0
        private void OnScopeCompleted(object sender, EventArgs e)
        {
            var scope = (Scope)sender;

            scope.Completed -= OnScopeCompleted;
            instances.TryRemove(scope, out object removedInstance);
        }
        internal void RemoveWrapper(Guid correlationId)
        {
            IRequestResponseCorrelationWrapper wrapper;

            _requestWrappers.TryRemove(correlationId, out wrapper);

            var disposable = wrapper as IDisposable;

            disposable?.Dispose();
        }
        private static Action Remove(ThreadSafeDictionary<string, string> dictionary)
        {
            return () =>
            {
                Thread.Sleep(50);
                for (int i = 0; i < 50; i++)
                {
                    string value;
                    dictionary.TryRemove("Key", out value);
                }

            };
        }
        /// <summary>
        /// Ends mocking the <paramref name="serviceType"/> with the given <paramref name="serviceName"/>.
        /// </summary>
        /// <param name="serviceRegistry">The target <see cref="IServiceRegistry"/> instance.</param>
        /// <param name="serviceType">The type of service for which to end mocking.</param>
        /// <param name="serviceName">The name of the service for which to end mocking.</param>
        public static void EndMocking(this IServiceRegistry serviceRegistry, Type serviceType, string serviceName)
        {
            var key = Tuple.Create(serviceRegistry, serviceType, serviceName);
            ServiceRegistration serviceRegistration;

            ServicesMocks.TryRemove(key, out serviceRegistration);

            if (serviceRegistration == null)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "No mocked service found. ServiceType: {0}, ServiceName: {1}", serviceType, serviceName));
            }

            serviceRegistration.IsReadOnly = false;

            if (MockedServices.TryRemove(key, out serviceRegistration))
            {
                serviceRegistry.Register(serviceRegistration);
            }
        }
Beispiel #5
0
        public static void DestroyInstance(Guid instanceId)
        {
            MethodCallCounter dummy;

            _instances.TryRemove(instanceId, out dummy);
        }