public void OctaneItemViewModelTests_SetActiveItem_SetValidItem_Success()
        {
            Assert.IsNull(OctaneItemViewModel.CurrentActiveItem, "There shouldn't be an active item");
            Assert.IsFalse(_taskViewModel.IsActiveWorkItem, "Task item shouldn't be active");
            Assert.IsFalse(_storyViewModel.IsActiveWorkItem, "Story item shouldn't be active");

            OctaneItemViewModel.SetActiveItem(_storyViewModel);

            Assert.AreEqual(_storyViewModel, OctaneItemViewModel.CurrentActiveItem, "Story item should be the active item");
            Assert.IsTrue(_storyViewModel.IsActiveWorkItem, "Story item should be the active after SetActiveItem");
        }
Exemple #2
0
        private void StopWork(object sender)
        {
            if (SelectedItem?.Entity == null)
            {
                return;
            }

            OctaneItemViewModel.ClearActiveItem();

            MainWindowCommand.Instance.UpdateActiveItemInToolbar();
        }
        public void OctaneItemViewModelTests_ClearActiveItem_ClearWhenThereIsNoActiveItem_Success()
        {
            Assert.IsNull(OctaneItemViewModel.CurrentActiveItem, "There shouldn't be an active item");
            Assert.IsFalse(_taskViewModel.IsActiveWorkItem, "Task item shouldn't be active");
            Assert.IsFalse(_storyViewModel.IsActiveWorkItem, "Story item shouldn't be active");

            OctaneItemViewModel.ClearActiveItem();

            Assert.IsNull(OctaneItemViewModel.CurrentActiveItem, "There shouldn't be an active item after ClearActiveItem");
            Assert.IsFalse(_taskViewModel.IsActiveWorkItem, "Task item shouldn't be active after ClearActiveItem");
            Assert.IsFalse(_storyViewModel.IsActiveWorkItem, "Story item shouldn't be active after ClearActiveItem");
        }
Exemple #4
0
        private void StartWork(object sender)
        {
            try
            {
                if (SelectedItem?.Entity == null)
                {
                    return;
                }

                OctaneItemViewModel.SetActiveItem(SelectedItem);

                MainWindowCommand.Instance.UpdateActiveItemInToolbar();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to start work on current item.\n\n" + "Failed with message: " + ex.Message, ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
        public static void ClassInit(TestContext context)
        {
            _storyEntity       = StoryUtilities.CreateStory();
            _taskEntity        = TaskUtilities.CreateTask(_storyEntity);
            _gherkinTestEntity = TestGherkinUtilities.CreateGherkinTest();

            var viewModel = new OctaneMyItemsViewModel();

            viewModel.LoadMyItemsAsync().Wait();

            _storyViewModel = viewModel.MyItems.FirstOrDefault(i => i.ID == _storyEntity.Id && i.Entity.Name == _storyEntity.Name);
            Assert.IsNotNull(_storyViewModel, "Couldn't find story entity in MyWork");

            _taskViewModel = viewModel.MyItems.FirstOrDefault(i => i.ID == _taskEntity.Id && i.Entity.Name == _taskEntity.Name);
            Assert.IsNotNull(_taskViewModel, "Couldn't find task entity in MyWork");

            _gherkinTestViewModel = viewModel.MyItems.FirstOrDefault(i => i.ID == _gherkinTestEntity.Id && i.Entity.Name == _gherkinTestEntity.Name);
            Assert.IsNotNull(_gherkinTestViewModel, "Couldn't find gherkin entity in MyWork");

            Assert.IsNull(OctaneItemViewModel.CurrentActiveItem, "There shouldn't be an active item");
        }
Exemple #6
0
        private static void StopWorkCallback(object caller, EventArgs args)
        {
            try
            {
                var command = caller as OleMenuCommand;
                if (command == null)
                {
                    return;
                }
                if (OctaneItemViewModel.CurrentActiveItem == null)
                {
                    return;
                }


                OctaneItemViewModel.ClearActiveItem();
                Instance.UpdateActiveItemInToolbar();
            } catch (Exception ex)
            {
                MessageBox.Show("Unable to stop work on current item.\n\n" + "Failed with message: " + ex.Message,
                                ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #7
0
        // TODO remove useMyItems and use a more generic mechanism to obtain the BaseItemViewModel
        private void ValidateContextMenuItems <T>(T entity, List <MenuItemEnum> expectedMenuItems, bool useMyItems = true, bool setActiveItem = false) where T : BaseEntity
        {
            try
            {
                BaseItemViewModel selectedItem;
                if (useMyItems)
                {
                    var viewModel = new OctaneMyItemsViewModel();
                    viewModel.LoadMyItemsAsync().Wait();

                    selectedItem = viewModel.MyItems.FirstOrDefault(i => i.ID == entity.Id);

                    if (setActiveItem)
                    {
                        OctaneItemViewModel.SetActiveItem(selectedItem as OctaneItemViewModel);
                    }
                }
                else
                {
                    selectedItem = new BaseItemViewModel(entity);
                }

                Assert.IsNotNull(selectedItem, "Couldn't find entity");

                var cm = new ContextMenu();

                ToolWindowHelper.ConstructContextMenu(cm, selectedItem,
                                                      _viewDetailsDelegate,
                                                      _viewTaskParentDetailsDelegate,
                                                      _viewCommentParentDetailsDelegate,
                                                      _openInBrowserDelegate,
                                                      _copyCommitMessageDelegate,
                                                      _downloadScriptDelegate,
                                                      _startWorkDelegate,
                                                      _stopWorkDelegate,
                                                      null,
                                                      null);

                Assert.AreEqual(expectedMenuItems.Count, cm.Items.Count,
                                "Mismatched number of menu items in context menu");

                var items = new MenuItem[cm.Items.Count];
                cm.Items.CopyTo(items, 0);

                int index = 0;
                foreach (var item in expectedMenuItems)
                {
                    switch (item)
                    {
                    case MenuItemEnum.ViewDetails:
                        ValidateMenuItem(items, index, ToolWindowHelper.ViewDetailsHeader, ViewDetailsValue);
                        break;

                    case MenuItemEnum.TaskViewParentDetails:
                        ValidateMenuItem(items, index, ToolWindowHelper.ViewTaskParentDetailsHeader, ViewTaskParentDetailsValue);
                        break;

                    case MenuItemEnum.CommentViewParentDetails:
                        ValidateMenuItem(items, index, ToolWindowHelper.CopyCommitMessageHeader, ViewCommentParentDetailsValue);
                        break;

                    case MenuItemEnum.OpenInBrowser:
                        ValidateMenuItem(items, index, ToolWindowHelper.OpenInBrowserHeader, OpenInBrowserValue);
                        break;

                    case MenuItemEnum.CopyCommitMessage:
                        ValidateMenuItem(items, index, ToolWindowHelper.CopyCommitMessageHeader, CopyCommitMessageValue);
                        break;

                    case MenuItemEnum.DownloadScript:
                        ValidateMenuItem(items, index, ToolWindowHelper.DownloadScriptHeader, DownloadScriptValue);
                        break;

                    case MenuItemEnum.StartWork:
                        ValidateMenuItem(items, index, ToolWindowHelper.StartWorkHeader, StartWorkValue);
                        break;

                    case MenuItemEnum.StopWork:
                        ValidateMenuItem(items, index, ToolWindowHelper.StopWorkHeader, StopWorkValue);
                        break;
                    }

                    index++;
                }
            }
            finally
            {
                EntityService.DeleteById <T>(WorkspaceContext, entity.Id);
            }
        }
 protected override void TestInitializeInternal()
 {
     OctaneItemViewModel.ClearActiveItem();
 }
 public void OctaneItemViewModelTests_SetActiveItem_NullItem_Success()
 {
     OctaneItemViewModel.SetActiveItem(null);
 }