Ejemplo n.º 1
0
        private void DoTestRemoveMinutia(int index)
        {
            using (Fake.CreateScope())
            {
                // PREPARE:
                m_Monitor.Reset();
                IEnumerable <MinutiaRecord> minutae = m_ViewModel.Minutae.ToArray();
                // Record the input minutia type before the operation
                MinutiaType inputType = m_ViewModel.InputMinutiaType;

                // EXECUTE:
                m_ViewModel.RemoveMinutia(index);

                // ASSERT:
                Assert.AreEqual(CAPTURE_NO_TEMPLATE, m_ViewModel.Capture);
                Assert.AreEqual(inputType, m_ViewModel.InputMinutiaType);
                Assert.AreEqual(m_ViewModel.Minutae.Count() > 0, m_IViewModel.IsSaveTemplatePermitted);
                Assert.AreEqual(0, m_Monitor.GetEventResponses <UserActionRequiredEventArgs>("UserActionRequired").Count());
                Assert.AreEqual(0, m_Monitor.GetEventResponses <PropertyChangedEventArgs>("PropertyChanged").Count());

                // Assert previous minuae are unchanged (note Equals has been overriden)
                Assert.AreEqual(minutae.Count() - 1, m_ViewModel.Minutae.Count());
                CollectionAssert.AreEqual(
                    minutae.Where((minutia, i) => i != index).ToArray(),
                    m_ViewModel.Minutae.ToArray());

                // Assert IDispatcherHelper interaction
                AssertNoCallsToDispatcherHelper();
            }
        }
        private void Minutia_MouseUp(object sender, MouseButtonEventArgs e)
        {
            m_Log.Debug("Minutia_MouseUp(...) called.");

            if (e.ChangedButton == MouseButton.Right)
            {
                object item  = (sender as FrameworkElement).DataContext;
                int    index = templatingItemsControl.Items.IndexOf(item);

                m_ViewModel.RemoveMinutia(index);

                // Mark event as handled so that we don't create a new minutia as soon as we have
                // deleted one.
                e.Handled = true;
            }
        }