コード例 #1
0
        void HandleSubCategoriesTagging(AnalysisEventButtonVM buttonVM, TagVM subcategoryTagged = null)
        {
            if (subcategoryTagged != null)
            {
                buttonVM.SelectedTags.Add(subcategoryTagged);
            }

            KeyTemporalContext tempContext = new KeyTemporalContext {
            };

            foreach (var subcategory in buttonVM.Tags)
            {
                KeyAction action = new KeyAction(new KeyConfig {
                    Name = subcategory.Value,
                    Key  = subcategory.HotKey.Model
                }, () => HandleSubCategoriesTagging(buttonVM, subcategory));
                tempContext.AddAction(action);
            }

            var analysisEventButton = (buttonVM.Model as AnalysisEventButton);

            if (analysisEventButton != null && analysisEventButton.TagMode == TagMode.Free)
            {
                tempContext.ExpiredTimeAction = buttonVM.ToggleIsCategoryClicked;
            }
            else
            {
                tempContext.Duration          = Constants.TEMP_TAGGING_DURATION;
                tempContext.ExpiredTimeAction = buttonVM.Click;
            }

            App.Current.KeyContextManager.AddContext(tempContext);
        }
コード例 #2
0
        public void Click_AnalysisEventButtonVM_NotifiesOk()
        {
            // Arrange
            AnalysisEventButton button = new AnalysisEventButton {
                EventType = new AnalysisEventType()
            };
            AnalysisEventButtonVM sut = new AnalysisEventButtonVM {
                Model = button
            };

            sut.CurrentTime = new Time();
            sut.SelectedTags.Add(new TagVM {
                Model = new Tag("hola")
            });
            bool       notified = false;
            List <Tag> tags     = null;

            App.Current.EventsBroker.Subscribe <NewTagEvent> ((e) => {
                notified = true;
                tags     = e.Tags.ToList();
            });

            // Act
            sut.Click();

            // Assert
            Assert.IsTrue(notified);
            Assert.AreEqual(1, tags.Count());
            Assert.AreEqual(0, sut.SelectedTags.Count());
        }
コード例 #3
0
        public void ModifyEventType_AddTags_PropertyChangedEmitted()
        {
            // Arrange
            AnalysisEventButton button = new AnalysisEventButton {
                EventType = new AnalysisEventType()
            };
            AnalysisEventButtonVM buttonVM = new AnalysisEventButtonVM {
                Model = button
            };
            bool   propertyChanged = false;
            string propertyName    = "";

            buttonVM.PropertyChanged += (sender, e) => {
                propertyChanged = true;
                propertyName    = e.PropertyName;
            };

            // Act
            ((AnalysisEventType)button.EventType).Tags.Add(new Tag("tag", "group"));

            // Assert
            Assert.IsTrue(propertyChanged);
            Assert.AreEqual("Collection_Tags", propertyName);
        }