public async Task MainPage_HasNavigationView()
        {
            List <NavigationView> actualNavViews = new List <NavigationView>();

            await UIService.FindAllAsync(actualNavViews);

            Assert.AreEqual(1, actualNavViews.Count, "MainPage should have exactly one NavigationView.");
        }
Ejemplo n.º 2
0
        public async Task CanvasPage_HasInkToolbar()
        {
            List <InkToolbar> actualToolbars = new List <InkToolbar>();

            await UIService.FindAllAsync(actualToolbars);

            Assert.AreEqual(1, actualToolbars.Count, "CanvasPage should have exactly one InkToolbars.");
        }
Ejemplo n.º 3
0
        public async Task InkToolbar_TargetCanvas_InkCanvas()
        {
            List <InkCanvas> canvases = new List <InkCanvas>();
            await UIService.FindAllAsync(canvases);

            List <InkToolbar> toolbars = new List <InkToolbar>();
            await UIService.FindAllAsync(toolbars);

            InkCanvas actualTargetCanvas = null;
            await UIService.RunOnUI(() => {
                actualTargetCanvas = toolbars[0].TargetInkCanvas;
            });

            Assert.AreEqual(canvases[0], actualTargetCanvas);
        }
Ejemplo n.º 4
0
        public async Task SetIsMouseEnabled_NewValue_UpdatesInkPresenterInputTypes()
        {
            bool?            expectedIsTouchEnabled = null;
            bool?            actualIsTouchEnabled   = null;
            List <InkCanvas> canvases = new List <InkCanvas>();
            await UIService.FindAllAsync(canvases);

            await UIService.RunOnUI(() => {
                expectedIsTouchEnabled =
                    !canvases[0].InkPresenter.InputDeviceTypes.HasFlag(CoreInputDeviceTypes.Mouse);

                MockCanvasViewModel.Instance.IsMouseInputEnabled = (bool)expectedIsTouchEnabled;
                actualIsTouchEnabled =
                    canvases[0].InkPresenter.InputDeviceTypes.HasFlag(CoreInputDeviceTypes.Mouse);
            });

            Assert.AreEqual(expectedIsTouchEnabled, actualIsTouchEnabled);
        }
        public async Task NavigationView_SelectionChanged_PassesSelectedTagToNavigationCommand()
        {
            object expectedTag = null;

            List <NavigationView> actualNavViews = new List <NavigationView>();
            await UIService.FindAllAsync(actualNavViews);

            List <NavigationViewItem> actualNavViewItems = new List <NavigationViewItem>();
            await UIService.FindAllAsync(actualNavViewItems);

            object actualTag = null;

            void CommandCalled(object parameter)
            {
                actualTag = parameter;
            }

            Mocks.MockMainViewModel.MockMainNavigationCommand.OnCommandCalled += CommandCalled;

            await UIService.RunOnUI(() => {
                for (int i = 0; i < actualNavViewItems.Count; i++)
                {
                    if (actualNavViewItems[i].Tag == null ||
                        actualNavViews[0].SelectedItem == actualNavViewItems[i])
                    {
                        continue;
                    }

                    expectedTag = actualNavViewItems[i].Tag;
                    actualNavViews[0].SelectedItem = actualNavViewItems[i];
                    break;
                }
            });


            if (expectedTag == null)
            {
                Assert.Fail("No NavigationViewItems found to select.");
            }

            Assert.AreEqual(expectedTag, actualTag);
        }
Ejemplo n.º 6
0
        public async Task SetInkData_NewInkStrokeContainer_UpdatesInkCanvas()
        {
            InkStrokeContainer expectedStrokeContainer = null;
            InkStrokeContainer actualStrokeContainer   = null;
            List <InkCanvas>   canvases = new List <InkCanvas>();
            await UIService.FindAllAsync(canvases);

            await UIService.RunOnUI(() => {
                expectedStrokeContainer = new InkStrokeContainer();
            });

            var mockInkData = new Mock <IInkData>();

            mockInkData.Setup(x => x.StrokeContainer).Returns(expectedStrokeContainer);

            await UIService.RunOnUI(() => {
                MockCanvasViewModel.Instance.InkData = mockInkData.Object;
                actualStrokeContainer = canvases[0].InkPresenter.StrokeContainer;
            });

            Assert.AreSame(expectedStrokeContainer, actualStrokeContainer);
        }