public async Task CanDisplaySavedForm()
        {
            // setup
            var mocker = new HomeViewModelMock();

            mocker.SetupSavedForm();

            // Act
            await mocker.FormPageViewModel.Initialise();

            // Verify
            Assert.AreEqual("Personal Details", mocker.FormPageViewModel.Title);
            Assert.AreEqual(13, mocker.FormPageViewModel.FormFields.Count);
            mocker.FileReaderWriterMock.VerifyAll();
        }
        public async Task WillNotSaveFormWhenNotValid()
        {
            // setup
            var mocker = new HomeViewModelMock();

            mocker.SetupSavedForm();
            mocker.MessageServiceMock.Setup(x => x.Send <string>(It.Is <string>(key => key == "FailedFormValidation"), It.IsAny <object>())).Verifiable();
            await mocker.FormPageViewModel.Initialise();

            // Act
            mocker.FormPageViewModel.SaveFormCommand.Execute(null);

            // Verify
            mocker.FileReaderWriterMock.Verify(x => x.SaveForm(It.IsAny <List <BaseControl> >(), It.IsAny <string>()), Times.Never());
            mocker.MessageServiceMock.VerifyAll();
        }
        public void CanExecuteClosePageCommand()
        {
            // setup
            var mocker = new HomeViewModelMock();

            mocker.SetupSavedForm();
            mocker.NavigationMock.Setup(x => x.PopAsync())
            .ReturnsAsync <INavigation, Page>(new Page());
            mocker.DeviceMock.Setup(x => x.BeginInvokeOnMainThread(It.IsAny <Action>()))
            .Callback <Action>((action) => action());

            // Act
            mocker.FormPageViewModel.ClosePageCommand.Execute(null);

            // Verify
            mocker.NavigationMock.VerifyAll();
        }