public void PropertiesTest()
 {
     var vm = new GadgetTabViewConverter();
     TestsHelper.TestPublicDeclaredPropertiesGetSet(vm, true);
 }
        /// <summary>
        /// Modifies the source data before passing it to the target for display in the UI.
        /// </summary>
        /// <param name="value">The source data being passed to the target.</param>
        /// <param name="targetType">The <see cref="T:System.Type" /> of data expected by the target dependency property.</param>
        /// <param name="parameter">An optional parameter to be used in the converter logic.</param>
        /// <param name="culture">The culture of the conversion.</param>
        /// <returns>The value to be passed to the target dependency property.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (DesignerProperties.IsInDesignTool)
                return value;

            var ComposedConverter = new GadgetTabViewConverter();

            lock (ComposedConverter)
            {
                if (ComposedConverter.Router == null)
                {
                    if (Router != null)
                    {
                        ComposedConverter.Router = Router;
                        ComposedConverter.Views = Views;
                    }
                    else
                        CompositionInitializer.SatisfyImports(ComposedConverter);
                }
            }

            if (_registeredViews == null) _registeredViews = new Dictionary<IGadgetTabViewModel, UserControl>();


            if (ComposedConverter.Router == null)
            {
                return value;
            }

            // if the value is a view model and a view tag was passed, resolve them
            var key = value as IGadgetTabViewModel;
            if (key != null)
            {
                //check if view is already regestered
                if (_registeredViews.ContainsKey(key))
                {
                    var view = _registeredViews[key];
                    cleanParentRef(view);
                    return view;
                }

                // first get the view model tag 
                var exportAttribute = key.GetType().GetCustomAttributes(true).OfType<ExportAsViewModelAttribute>().FirstOrDefault();
                if (exportAttribute == null)
                {
                    return value;
                }

                var viewModelTag = exportAttribute.ViewModelType;
                var views = ComposedConverter.Router.Value.GetViewTagsForViewModel(viewModelTag);

                UserControl result = null;

                // we always assume the first view
                if (views.Length > 0)
                {
                    result = ComposedConverter.Router.Value.GetNonSharedView(views[0], key);

                    if (result == null)
                    {
                        var viewEntry = ComposedConverter.Views.FirstOrDefault(v => v.Metadata.ExportedViewType.Equals(views[0]));
                        if (viewEntry != null)
                            result = viewEntry.Value;
                    }
                }

                if (result != null)
                {
                    result.DataContext = value;
                    _registeredViews.Add(key, result);

                    cleanParentRef(result);

                    return result;
                }
            }

            return value;
        }