public void RefreshProperties()
        {
            var node = tvWorkitems.SelectedNode;
            WorkitemDescriptor descriptor = null;

            if (node != null)
            {
                var oldDescriptor = (WorkitemDescriptor)node.Tag;
                descriptor = oldDescriptor.GetDetailedDescriptor(
                    configuration.AssetDetail.GetColumns(oldDescriptor.Workitem.TypePrefix),
                    PropertyUpdateSource.WorkitemPropertyView);
            }

            UpdatePropertyView(descriptor);
        }
        protected void UpdatePropertyView(WorkitemDescriptor selectedItem)
        {
            //Try to get PropertiesFrame
            if (propertiesFrame == null)
            {
                var shell = GetService <IVsUIShell>(typeof(SVsUIShell));

                if (shell != null)
                {
                    var guidPropertyBrowser = new Guid(ToolWindowGuids.PropertyBrowser);
                    shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref guidPropertyBrowser, out propertiesFrame);
                }
            }

            if (propertiesFrame == null)
            {
                return;
            }

            int visible;

            propertiesFrame.IsOnScreen(out visible);

            if (visible == 1)
            {
                propertiesFrame.ShowNoActivate(); // Show() in original
            }

            var selectionContainer = new SelectionContainer();

            if (selectedItem != null)
            {
                selectionContainer.SelectedObjects = new object[] { selectedItem };
                CurrentWorkitemId = selectedItem.Entity.Id;
            }
            else
            {
                CurrentWorkitemId = null;
            }

            var track = GetService <ITrackSelection>(typeof(STrackSelection));

            if (track != null)
            {
                track.OnSelectChange(selectionContainer);
            }
        }
        public void RevertNonVirtualItem()
        {
            var workitemMock = mockRepository.PartialMock <TestWorkitem>(Guid.NewGuid().ToString(), false, assetCacheMock);
            var descriptor   = new WorkitemDescriptor(workitemMock, new ColumnSetting[0], PropertyUpdateSource.WorkitemView, true);

            ExpectRegisterAndPrepareView();
            Expect.Call(viewMock.CurrentWorkitemDescriptor).Return(descriptor);
            Expect.Call(workitemMock.RevertChanges);
            Expect.Call(viewMock.RefreshProperties);
            Expect.Call(viewMock.Refresh);

            mockRepository.ReplayAll();

            controller.Register(viewMock);
            controller.PrepareView();
            controller.RevertItem();

            mockRepository.VerifyAll();
        }
        public void QuickCloseItem()
        {
            var workitemMock = mockRepository.PartialMock <TestWorkitem>(Guid.NewGuid().ToString(), false, assetCacheMock);
            var descriptor   = new WorkitemDescriptor(workitemMock, new ColumnSetting[0], PropertyUpdateSource.WorkitemView, true);

            ExpectRegisterAndPrepareView();
            Expect.Call(viewMock.CurrentWorkitemDescriptor).Return(descriptor);
            Expect.Call(viewMock.GetWaitCursor()).Return(waitCursorStub);
            Expect.Call(workitemMock.QuickClose);
            Expect.Call(() => eventDispatcherMock.Notify(null, new ModelChangedArgs(EventReceiver.WorkitemView, EventContext.WorkitemsChanged)));

            mockRepository.ReplayAll();

            controller = new TestWorkitemTreeController(loggerFactoryMock, dataLayerMock, configuration, settingsMock, eventDispatcherMock);
            controller.Register(viewMock);
            controller.PrepareView();
            controller.QuickCloseItem();

            mockRepository.VerifyAll();
        }
        public void AddTask()
        {
            var parentWorkitemMock = mockRepository.PartialMock <TestWorkitem>(Guid.NewGuid().ToString(), true, assetCacheMock);
            var workitemMock       = mockRepository.PartialMock <TestWorkitem>(Guid.NewGuid().ToString(), false, assetCacheMock);
            var descriptor         = new WorkitemDescriptor(parentWorkitemMock, new ColumnSetting[0], PropertyUpdateSource.WorkitemView, true);

            ExpectRegisterAndPrepareView();
            Expect.Call(viewMock.CurrentWorkitemDescriptor).Return(descriptor);
            Expect.Call(dataLayerMock.CreateWorkitem(Entity.TaskType, parentWorkitemMock, assetCacheMock)).Return(workitemMock);
            Expect.Call(() => eventDispatcherMock.Notify(null, new ModelChangedArgs(EventReceiver.WorkitemView, EventContext.WorkitemsChanged)));
            Expect.Call(viewMock.ExpandCurrentNode);
            Expect.Call(() => viewMock.SelectWorkitem(workitemMock));
            Expect.Call(viewMock.Refresh);
            Expect.Call(viewMock.RefreshProperties);

            mockRepository.ReplayAll();
            controller.Register(viewMock);
            controller.PrepareView();
            controller.AddTask();
            mockRepository.VerifyAll();
        }
        public void CommitItemValidationFailure()
        {
            var workitemMock = mockRepository.PartialMock <TestWorkitem>(Guid.NewGuid().ToString(), true, assetCacheMock);
            var descriptor   = new WorkitemDescriptor(workitemMock, new ColumnSetting[0], PropertyUpdateSource.WorkitemView, true);

            ExpectRegisterAndPrepareView();
            Expect.Call(viewMock.CurrentWorkitemDescriptor).Return(descriptor);
            Expect.Call(viewMock.GetWaitCursor()).Return(waitCursorStub);
            Expect.Call(workitemMock.CommitChanges).Throw(new ValidatorException(null));
            Expect.Call(() => viewMock.ShowErrorMessage(null)).IgnoreArguments();
            Expect.Call(() => eventDispatcherMock.Notify(null, new ModelChangedArgs(EventReceiver.WorkitemView, EventContext.WorkitemsChanged)));

            mockRepository.ReplayAll();

            controller = new TestWorkitemTreeController(loggerFactoryMock, dataLayerMock, configuration, settingsMock, eventDispatcherMock);
            controller.Register(viewMock);
            controller.PrepareView();
            controller.CommitItem();

            mockRepository.VerifyAll();
        }