Пример #1
0
        public void UpdatingTheTypeNameToASingleMatch_PerformsSearchAndSetsSelectionButDoesNotChangeTypeName()
        {
            var groups =
                new[] {
                new AssemblyGroup(
                    "test",
                    new[] {
                    typeof(TestAssembly1.Namespace1.Class1).Assembly,
                    typeof(TestAssembly2.Namespace1.Class1).Assembly
                })
            };

            var model = new TypeBrowserViewModel(null);

            model.UpdateAssemblyGroups(groups);

            var modifiedProperties = new List <string>();

            model.PropertyChanged += (s, a) =>
            {
                modifiedProperties.Add(a.PropertyName);
            };

            var frame = new DispatcherFrame();

            model.AssemblyGroups[0].Assemblies[0].Namespaces[0].PropertyChanged += (s, a) =>
            {
                frame.Continue = false;
            };

            model.TypeName = "NamespaceClass";
            Dispatcher.PushFrame(frame);

            Assert.IsNotNull(model.ConcreteType);
            Assert.AreEqual("NamespaceClass", model.TypeName);
            TreeAssert.IsMatch(
                new
            {
                DisplayName = "test",
                Assemblies  = new object[]
                {
                    new
                    {
                        DisplayName = "TestAssembly1",
                        Visibility  = Visibility.Collapsed, IsExpanded = false,
                        Namespaces  = new object []
                        {
                            new
                            {
                                DisplayName = "TestAssembly1.Namespace1",
                                Visibility  = Visibility.Collapsed, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "Class1",
                                        FullName    = "TestAssembly1.Namespace1.Class1",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "Class2",
                                        FullName    = "TestAssembly1.Namespace1.Class2",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "InternalClass1",
                                        FullName    = "TestAssembly1.Namespace1.InternalClass1",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    },
                                }
                            },
                            new
                            {
                                DisplayName = "TestAssembly1.Namespace2",
                                Visibility  = Visibility.Collapsed, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "AnotherInternalClass",
                                        FullName    = "TestAssembly1.Namespace2.AnotherInternalClass",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    }
                                }
                            }
                        }
                    },
                    new
                    {
                        DisplayName = "TestAssembly2",
                        Visibility  = Visibility.Visible, IsExpanded = true,
                        Namespaces  = new object []
                        {
                            new
                            {
                                DisplayName = "TestAssembly2",
                                Visibility  = Visibility.Visible, IsExpanded = true,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "Class1",
                                        FullName    = "TestAssembly2.Class1",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "NamespaceClass",
                                        FullName    = "TestAssembly2.NamespaceClass",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    }
                                }
                            },
                            new
                            {
                                DisplayName = "TestAssembly2.Namespace1",
                                Visibility  = Visibility.Collapsed, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "Class1",
                                        FullName    = "TestAssembly2.Namespace1.Class1",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "Class12",
                                        FullName    = "TestAssembly2.Namespace1.Class12",
                                        Visibility  = Visibility.Collapsed, IsExpanded = false
                                    }
                                }
                            }
                        }
                    }
                }
            },
                model.AssemblyGroups[0]);
        }
Пример #2
0
        public void ViewModelIsInitialized()
        {
            var groups =
                new[] {
                new AssemblyGroup(
                    "test",
                    new[] {
                    typeof(TestAssembly1.Namespace1.Class1).Assembly,
                    typeof(TestAssembly2.Namespace1.Class1).Assembly
                })
            };

            var model = new TypeBrowserViewModel(null);

            model.UpdateAssemblyGroups(groups);

            Assert.IsNull(model.TypeName);
            Assert.IsNull(model.ConcreteType);
            Assert.IsFalse(model.HasGenericParameters);
            Assert.AreEqual(0, model.GenericTypeParameters.Count);
            TreeAssert.IsMatch(
                new
            {
                DisplayName = "test",
                Assemblies  = new object[]
                {
                    new
                    {
                        DisplayName = "TestAssembly1",
                        Visibility  = Visibility.Visible, IsExpanded = false,
                        Namespaces  = new object []
                        {
                            new
                            {
                                DisplayName = "TestAssembly1.Namespace1",
                                Visibility  = Visibility.Visible, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "Class1",
                                        FullName    = "TestAssembly1.Namespace1.Class1",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "Class2",
                                        FullName    = "TestAssembly1.Namespace1.Class2",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "InternalClass1",
                                        FullName    = "TestAssembly1.Namespace1.InternalClass1",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    },
                                }
                            },
                            new
                            {
                                DisplayName = "TestAssembly1.Namespace2",
                                Visibility  = Visibility.Visible, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "AnotherInternalClass",
                                        FullName    = "TestAssembly1.Namespace2.AnotherInternalClass",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    }
                                }
                            }
                        }
                    },
                    new
                    {
                        DisplayName = "TestAssembly2",
                        Visibility  = Visibility.Visible, IsExpanded = false,
                        Namespaces  = new object []
                        {
                            new
                            {
                                DisplayName = "TestAssembly2",
                                Visibility  = Visibility.Visible, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "Class1",
                                        FullName    = "TestAssembly2.Class1",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "NamespaceClass",
                                        FullName    = "TestAssembly2.NamespaceClass",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    }
                                }
                            },
                            new
                            {
                                DisplayName = "TestAssembly2.Namespace1",
                                Visibility  = Visibility.Visible, IsExpanded = false,
                                Types       = new object[]
                                {
                                    new
                                    {
                                        DisplayName = "Class1",
                                        FullName    = "TestAssembly2.Namespace1.Class1",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    },
                                    new
                                    {
                                        DisplayName = "Class12",
                                        FullName    = "TestAssembly2.Namespace1.Class12",
                                        Visibility  = Visibility.Visible, IsExpanded = false
                                    }
                                }
                            }
                        }
                    }
                }
            },
                model.AssemblyGroups[0]);
        }