Exemplo n.º 1
0
        public void DismissFromMyWork()
        {
            // wait for elastic search to update created entities
            Thread.Sleep(30000);
            Run(async() => {
                var viewModel = new OctaneMyItemsViewModel();

                List <BaseEntity> searchedEntities = (List <BaseEntity>) await OctaneServices.GetInstance().SearchEntities(_dismissedStory.Id, 1);
                if (searchedEntities.Count != 1)
                {
                    Assert.Fail("Failed to search created story by id");
                }
                await MyWorkUtils.AddToMyWork(searchedEntities[0]);

                await viewModel.LoadMyItemsAsync();

                var searchedMyWorkItem = viewModel.MyItems.ToList().Find(ui => ui.ID.Equals(_dismissedStory.Id));
                Assert.IsTrue(searchedMyWorkItem.ID.Equals(_dismissedStory.Id));

                await MyWorkUtils.RemoveFromMyWork(searchedMyWorkItem.Entity);
                await viewModel.LoadMyItemsAsync();

                searchedMyWorkItem = viewModel.MyItems.ToList().Find(ui => ui.ID.Equals(_dismissedStory.Id));
                Assert.IsTrue(searchedMyWorkItem == null);
            }).Wait();
        }
Exemplo n.º 2
0
        public void OctaneMyItemsViewModelTests_Refresh_ItemRemoved_Success()
        {
            var  defect  = DefectUtilities.CreateDefect();
            bool removed = false;

            try
            {
                var viewModel = new OctaneMyItemsViewModel();
                viewModel.LoadMyItemsAsync().Wait();

                var myItems = viewModel.MyItems.ToList();
                Assert.AreEqual(1, myItems.Count(item => item.ID == defect.Id), $"Couldn't find entity {defect.Name}");

                EntityService.DeleteById <Defect>(WorkspaceContext, defect.Id);
                removed = true;

                viewModel.RefreshCommand.Execute(null);

                Utility.WaitUntil(() => viewModel.Mode == MainWindowMode.ItemsLoaded,
                                  "Timeout waiting for Refresh to finish", new TimeSpan(0, 0, 30));

                myItems = viewModel.MyItems.ToList();
                Assert.AreEqual(0, myItems.Count(item => item.ID == defect.Id), $"Found previously deleted entity {defect.Name} after refresh");
            }
            finally
            {
                if (!removed)
                {
                    EntityService.DeleteById <Defect>(WorkspaceContext, defect.Id);
                }
            }
        }
Exemplo n.º 3
0
        public void OctaneMyItemsViewModelTests_SearchHistory_SearchForMoreThanMax_Success()
        {
            var viewModel = new OctaneMyItemsViewModel();

            viewModel.LoadMyItemsAsync().Wait();

            var expectedHistory = ExecuteSearches(viewModel, WorkspaceSessionPersistanceManager.MaxSearchHistorySize + 1);

            expectedHistory.Reverse();

            CollectionAssert.AreEqual(expectedHistory.Take(WorkspaceSessionPersistanceManager.MaxSearchHistorySize).ToList(), viewModel.SearchHistory.ToList(), "Invalid search history");
        }
Exemplo n.º 4
0
        private void ValidateType <T>(T entity, int expectedCount) where T : BaseEntity
        {
            try
            {
                var viewModel = new OctaneMyItemsViewModel();
                viewModel.LoadMyItemsAsync().Wait();

                Assert.AreEqual(expectedCount, viewModel.MyItems.Count(i => i.ID == entity.Id && i.Entity.Name == entity.Name),
                                $"Couldn't find exactly one entity with the name {entity.Name}");
            }
            finally
            {
                EntityService.DeleteById <T>(WorkspaceContext, entity.Id);
            }
        }
        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");
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initialize the data for the control
 /// </summary>
 internal void Initialize()
 {
     _viewModel.LoadMyItemsAsync();
 }
Exemplo n.º 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);
            }
        }