public void IsExpandedTest()
        {
            const int ItemId = 111;

            var parentModelMock = Mock.Create<IEditableRootWithTreeView>(Behavior.Loose);
            Mock.Arrange(() => parentModelMock.ProcessName).Returns("StrongName");

            var detailViewModelMock = Mock.Create<IDetailsViewModel>(Behavior.Loose);

            var masterItem = Mock.Create<ITreeViewItem>(Behavior.Loose);

            Mock.Arrange(() => masterItem.Id).Returns(ItemId);
            Mock.Arrange(() => masterItem.Level).Returns(-1);
            Mock.Arrange(() => masterItem.MasterId).Returns(6);
            Mock.Arrange(() => masterItem.ChildId).Returns(7);

            var childItem = Mock.Create<ITreeViewItem>(Behavior.Loose);

            Mock.Arrange(() => childItem.Id).Returns(ItemId);
            Mock.Arrange(() => childItem.Level).Returns(0);
            Mock.Arrange(() => childItem.MasterId).Returns(7);
            Mock.Arrange(() => childItem.ChildId).Returns(8);

            var list = new List<ITreeViewItem> { masterItem, childItem };
            var dynamicTypeManagerMock = Mock.Create<IDynamicTypeManager>(Behavior.Loose);
            Mock.Arrange(() => dynamicTypeManagerMock.BeginGetReverseCrossReferenceList(Arg.IsAny<string>(), Arg.IsAny<string>(), 6, Arg.IsAny<Action<object, IDataPortalResult>>()))
                .DoInstead<string, string, int, Action<object, IDataPortalResult>>(
                    (processName, propertyName, masterId, callback) =>
                    {
                        var result = Mock.Create<IDataPortalResult>(Behavior.Loose);
                        Mock.Arrange(() => result.Error).Returns(null as Exception);
                        Mock.Arrange(() => result.Object).Returns(list);
                        callback(null, result);
                    });

            var parent = Mock.Create<TreeViewFieldViewModel>(Behavior.Loose);
            parent.Init(parentModelMock, parent, detailViewModelMock);
            Mock.Arrange(() => parent.ParentModel).Returns(parentModelMock);
            Mock.Arrange(() => parent.Property).Returns(ReflectionHelper.GetProperty<IEditableRootWithTreeView>(x => x.TreeView));
           
            var tag1 = new TreeViewItemViewModel { DynamicTypeManager = dynamicTypeManagerMock, Item = masterItem };

            var tag2 = new TreeViewItemViewModel { DynamicTypeManager = dynamicTypeManagerMock, Item = masterItem };

            parent.Items.Add(new ExportFactory<TreeViewItemViewModel>(() => new Tuple<TreeViewItemViewModel, Action>(tag1, () => { })).CreateExport().Value);

            parent.Items.Add(new ExportFactory<TreeViewItemViewModel>(() => new Tuple<TreeViewItemViewModel, Action>(tag2, () => { })).CreateExport().Value);

            tag1.ParentFieldViewModel = parent;
            
            parent.Items[0].IsExpanded = true;
        }
        public void ShowCommand_Shows_SelectedItem()
        {
            // Arrange.
            const string ProcessName = "TestProcess";
            const int ItemId = 111;
            const int Level = -1;
            const int MasterId = 6;
            const int ChildId = 7;

            var treeViewItem = Mock.Create<ITreeViewItem>();
            Mock.Arrange(() => treeViewItem.Id).Returns(ItemId);
            Mock.Arrange(() => treeViewItem.Level).Returns(Level);
            Mock.Arrange(() => treeViewItem.MasterId).Returns(MasterId);
            Mock.Arrange(() => treeViewItem.ChildId).Returns(ChildId);

            var parentVM = Mock.Create<TreeViewFieldViewModel>();

            var tag = new TreeViewItemViewModel { Item = treeViewItem };

            parentVM.TreeViewItemViewModelFactory = new ExportFactory<TreeViewItemViewModel>(() => new Tuple<TreeViewItemViewModel, Action>(tag, () => { }));

            parentVM.Items.Add(parentVM.TreeViewItemViewModelFactory.CreateExport().Value);

            var detailsViewModel = Mock.Create<IDetailsViewModel>();
            var parentViewModel = Mock.Create<IDetailsViewModel>();
            var windowManager = Mock.Create<IShell>();

            var target = new TreeViewFieldViewModel();
            target.ReferenceName = ProcessName;
            target.SelectedItem = parentVM.Items[0];
            target.WindowManager = windowManager;
            target.ParentDetailsVM = parentViewModel;
            target.DetailsViewModelFactory = new ExportFactory<IDetailsViewModel>(() => new Tuple<IDetailsViewModel, Action>(detailsViewModel, () => { }));

            // Act.
            target.ShowCommand.Execute(null);

            // Assert.
            Mock.Assert(() => detailsViewModel.Refresh(ProcessName, ItemId), Occurs.Once());
            Mock.Assert(() => windowManager.ShowChildWindow(parentViewModel, detailsViewModel, null), Occurs.Once());
        }