예제 #1
0
        public void TestOnResetPasswordFailEmpty()
        {
            Mock <IAuth> authMock = new Mock <IAuth>(MockBehavior.Strict);

            authMock.Setup(a => a.SendPasswordResetEmailAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(true));

            Mock <INavigationService> navigationMock = new Mock <INavigationService>(MockBehavior.Strict);

            ForgotPasswordViewModel forgotPassVM = new ForgotPasswordViewModel(authMock.Object, navigationMock.Object);

            forgotPassVM.OnResetPassword();

            Assert.IsTrue(forgotPassVM.ErrorVis);
            authMock.Verify(a => a.SendPasswordResetEmailAsync(It.IsAny <string>()), Times.Never);
        }
예제 #2
0
        public void TestOnResetPasswordSucess()
        {
            Mock <IAuth> authMock = new Mock <IAuth>(MockBehavior.Strict);

            authMock.Setup(a => a.SendPasswordResetEmailAsync(It.IsAny <string>()))
            .Returns(Task.FromResult(true));

            Mock <INavigationService> navigationMock = new Mock <INavigationService>(MockBehavior.Strict);

            navigationMock.Setup(a => a.NavigateToLogin()).Returns(Task.CompletedTask);


            ForgotPasswordViewModel forgotPassVM = new ForgotPasswordViewModel(authMock.Object, navigationMock.Object)
            {
                Email = "*****@*****.**"
            };

            forgotPassVM.OnResetPassword();

            Assert.IsFalse(forgotPassVM.ErrorVis);
            authMock.Verify(a => a.SendPasswordResetEmailAsync(It.IsAny <string>()), Times.Once);
            navigationMock.Verify(a => a.NavigateToLogin(), Times.Once);
        }