Exemplo n.º 1
0
 private void Loader_PluginLoaded(object sender, PluginLoadedEventArgs e)
 {
     if (OptionUtility.HasConfigurationFile(e.Plugin))
     {
         var proxy = new ConfigurationProxy(() => OptionUtility.GetConfiguration(e.Plugin));
         OptionManager.Instance.Providers.Add(proxy);
     }
 }
        public static string GetServiceBehaviorElementXml(this IEnumerable <BehaviorExtensionElement> serviceBehaviors)
        {
            var serviceBehaviorElement = new ServiceBehaviorElement("ServiceBehavior");

            serviceBehaviors.Each(b => serviceBehaviorElement.Add(b));

            var configurationProxy = new ConfigurationProxy();

            configurationProxy.SetServiceBehaviorElement(serviceBehaviorElement);
            return(configurationProxy.GetServiceBehaviorElementXml());
        }
        public static string GetEndpointBehaviorElementXml(this IEnumerable <BehaviorExtensionElement> endpointBehaviors)
        {
            var endpointBehaviorElement = new EndpointBehaviorElement("EndpointBehavior");

            endpointBehaviors.Each(b => endpointBehaviorElement.Add(b));

            var configurationProxy = new ConfigurationProxy();

            configurationProxy.SetEndpointBehaviorElement(endpointBehaviorElement);
            return(configurationProxy.GetEndpointBehaviorElementXml());
        }
        /// <summary>
        /// Exercise mock server
        /// </summary>
        public void given_data_is_being_sent_and_received_to_the_server()
        {
            var mock  = new PretendsToBeConnectedToHttpClient();
            var proxy = new ConfigurationProxy(mock);

            it["then its possible to submit valid configuration"] = () =>
            {
                var result = proxy.Store(_serializationTarget);
                result[StatusKey.Status].should_be(StatusCode.Ok);
            };
            it["then the original object is retrieved on get"] = () => proxy.Retrieve().should_be(_serializationTarget);
        }
        public void given_a_url_is_provided_on_construction()
        {
            const string baseUrl     = "http://www.google.com/";
            var          expectedUrl = new Uri(new Uri(baseUrl), UriElements.ConfigurationPath).ToString();
            var          target      = new ConfigurationProxy(null, "http://www.google.com/");

            context["when i retrieve the listener url form the configurationProxy instance"] = () =>
            {
                var retrievedUrl = target.ConfigurationUrl;
                it["then the provided url is returned"] = () => retrievedUrl.should_be(expectedUrl);
            };
        }
 public static string GetBindingElementXml(this ConfigurationElement configurationElement, string bindingName)
 {
     if (configurationElement is IBindingElementDecorator bindingElementDecorator)
     {
         configurationElement = (ConfigurationElement)bindingElementDecorator.DecoratedBindingElement;
     }
     using (var configurationProxy = new ConfigurationProxy())
     {
         configurationProxy.SetBindingElement(configurationElement);
         return(configurationProxy.GetBindingElementXml(bindingName));
     }
 }
        public static string GetBindingElementXml(this ConfigurationElement configurationElement, string bindingName)
        {
            var bindingElementDecorator = configurationElement as IBindingElementDecorator;

            if (bindingElementDecorator != null)
            {
                configurationElement = (ConfigurationElement)bindingElementDecorator.DecoratedBindingElement;
            }

            var configurationProxy = new ConfigurationProxy();

            configurationProxy.SetBindingElement(configurationElement);
            return(configurationProxy.GetBindingElementXml(bindingName));
        }
        public void given_a_url_is_not_provided_on_construction()
        {
            var target = new ConfigurationProxy();

            context["when i retrieve the listener and configuration url from the configurationProxy instance"] = () =>
            {
                var configUrl          = target.ConfigurationUrl;
                var listenerUrl        = target.ListenerUrl;
                var defaultProvider    = new DefaultConfigurationProvider();
                var defaultConfigUrl   = defaultProvider.ConfigurationUrl.ToString();
                var defaultListenerUrl = defaultProvider.TfsListenerUrl.ToString();
                it["then the default url is returned"] = () =>
                {
                    configUrl.should_be(defaultConfigUrl);
                    listenerUrl.should_be(defaultListenerUrl);
                };
            };
        }
        void IBaseAdapter.Run(ITestElement testElement, ITestContext testContext)
        {
            Thread myThread = Thread.CurrentThread;

            try
            {
                // Make sure to abort the previous test's Run thread if it isn't done yet - this could happen if a test times out
                Thread threadToAbort;
                lock (m_runThreadLock)
                {
                    threadToAbort = m_runThread;
                    m_runThread   = myThread;
                }
                AbortThread(threadToAbort);

                //Register configuration proxy to merge test configuration with VS
                ConfigurationProxy.Register(testElement.Storage);

                ITestAdapter realAdapter = GetTestAdapter(testElement);
                realAdapter.Run(testElement, testContext);
            }
            catch (ThreadAbortException)
            {
                // The agent-side adapter's thread that called this method may have already been aborted due to a timeout, so
                // don't send this exception back
                Thread.ResetAbort();
            }
            finally
            {
                lock (m_runThreadLock)
                {
                    if (m_runThread != null && m_runThread.ManagedThreadId == myThread.ManagedThreadId)
                    {
                        m_runThread = null;
                    }
                }
            }
        }
Exemplo n.º 10
0
        private void Loader_PluginLoaded(object sender, PluginLoadedEventArgs e)
        {
            var proxy = new ConfigurationProxy(() => OptionUtility.GetConfiguration(e.Plugin));

            e.Plugin.Context.ApplicationContext.OptionManager.Providers.Add(proxy);
        }