Example #1
0
        private void DoTestSetMinutia()
        {
            using (Fake.CreateScope())
            {
                // PREPARE:
                m_Monitor.Reset();
                // Create a random point to update the minutia with
                Point setPosition = new Point(
                    m_Random.Next(MAX_IMAGE_SIZE),
                    m_Random.Next(MAX_IMAGE_SIZE));
                // Copy the minutae before the operation
                IEnumerable <MinutiaRecord> minutae = m_ViewModel.Minutae.ToArray();
                // Record the input minutia type before the operation
                MinutiaType inputType = m_ViewModel.InputMinutiaType;

                // EXECUTE:
                m_ViewModel.PositionInput(setPosition);

                // ASSERT:
                Assert.AreEqual(CAPTURE_NO_TEMPLATE, m_ViewModel.Capture);
                Assert.AreEqual(inputType, m_ViewModel.InputMinutiaType);
                Assert.AreEqual(minutae.Count(), m_ViewModel.Minutae.Count);
                Assert.AreEqual((m_ViewModel.Minutae.Count() > 0), m_IViewModel.IsSaveTemplatePermitted);

                // Assert that the user is prompted to add a new minutia
                IEnumerable <UserActionRequiredEventArgs> userActionEvents = m_Monitor.GetEventResponses <UserActionRequiredEventArgs>("UserActionRequired");
                Assert.AreEqual(1, userActionEvents.Count());
                Assert.AreEqual(INPUT_MINUTIA_PROMPT, userActionEvents.ElementAt(0).PromptText);

                // Assert that no bound properties were changed
                Assert.AreEqual(0, m_Monitor.GetEventResponses <PropertyChangedEventArgs>("PropertyChanged").Count());

                // Assert previous minuae are unchanged (note Equals has been overridden)
                Assert.AreEqual(minutae.Count(), m_ViewModel.Minutae.Count());
                CollectionAssert.AreEqual(
                    minutae.Take(minutae.Count() - 1).ToArray(),
                    m_ViewModel.Minutae.Take(minutae.Count() - 1).ToArray());
                // Assert set minutia properties
                Assert.AreEqual(minutae.Last().Position, m_ViewModel.Minutae.Last().Position);
                Assert.AreEqual(minutae.Last().Type, m_ViewModel.Minutae.Last().Type);
                Assert.AreEqual(inputType, m_ViewModel.Minutae.Last().Type);

                Vector direction = (setPosition - minutae.Last().Position);
                Assert.AreEqual(
                    MathsHelper.RadianToDegree(Math.Atan2(direction.Y, direction.X)),
                    m_ViewModel.Minutae.Last().Angle);

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

            Point scaled_pos = e.GetPosition(sender as IInputElement);
            // Account for image scaling
            Point pos = scaled_pos.InvScale(Scale);

            // Pass the pixels of the image
            m_ViewModel.PositionInput(pos);
        }