コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }