예제 #1
0
        // Esemenykezelok //

        private async void Login_ClickAsync(object sender, RoutedEventArgs e)
        {
            await viewModel.LoginAsync();

            if (viewModel.AppUser != null)
            {
                NavigateToConcertsPage();
            }
            else
            {
                await new MessageDialog("Sikertelen bejelentkezés!").ShowAsync();
            }
        }
예제 #2
0
        public async Task LoginAsync_ShouldShowEmailEmptyError_WhenEmailIsEmpty()
        {
            // Arrange
            var authServiceMock         = new Mock <IAuthenticationService>();
            var navigationServiceMock   = new Mock <INavigationService>();
            var authenticationViewModel = new AuthenticationViewModel(authServiceMock.Object, navigationServiceMock.Object);

            // Act
            authenticationViewModel.LoginAsync();

            // Assert
            Assert.Equal(AppResources.LoginView_EmailEmpty, authenticationViewModel.Message);
            Assert.True(string.IsNullOrEmpty(authenticationViewModel.Email));
        }
예제 #3
0
        public async Task LoginAsync_ShouldShowApiKeyError_WhenApiKeyIsEmpty()
        {
            // Arrange
            var authServiceMock         = new Mock <IAuthenticationService>();
            var navigationServiceMock   = new Mock <INavigationService>();
            var authenticationViewModel = new AuthenticationViewModel(authServiceMock.Object, navigationServiceMock.Object);

            authenticationViewModel.Email    = "*****@*****.**";
            authenticationViewModel.Password = "******";
            // Act
            authenticationViewModel.LoginAsync();

            // Assert
            Assert.Equal(AppResources.LoginView_ApiKeyEmpty, authenticationViewModel.Message);
            Assert.True(string.IsNullOrEmpty(authenticationViewModel.ApiKey));
        }
예제 #4
0
        public async Task LoginAsync_ShouldShowCredentialInvalid_WhenServerLoginFailed()
        {
            // Arrange
            var authServiceMock = new Mock <IAuthenticationService>();

            authServiceMock
            .Setup(auth => auth.LoginAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new Result <bool, string>(errorValue: "errorMsg"));
            var navigationServiceMock   = new Mock <INavigationService>();
            var authenticationViewModel = new AuthenticationViewModel(authServiceMock.Object, navigationServiceMock.Object);

            authenticationViewModel.Email    = "*****@*****.**";
            authenticationViewModel.Password = "******";
            authenticationViewModel.ApiKey   = "ApiKey";

            // Act
            authenticationViewModel.LoginAsync();

            // Assert
            Assert.Equal(AppResources.LoginView_InvalidCredentialsError, authenticationViewModel.Message);
            Assert.False(string.IsNullOrEmpty(authenticationViewModel.Password));
            Assert.False(string.IsNullOrEmpty(authenticationViewModel.Email));
            Assert.False(string.IsNullOrEmpty(authenticationViewModel.ApiKey));
        }
예제 #5
0
        public async Task LoginAsync_ShouldNotShowAnyError_WhenServerLoginIsSuccessful()
        {
            // Arrange
            var authServiceMock = new Mock <IAuthenticationService>();

            authServiceMock
            .Setup(auth => auth.LoginAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new Result <bool, string>(true));
            var navigationServiceMock   = new Mock <INavigationService>();
            var authenticationViewModel = new AuthenticationViewModel(authServiceMock.Object, navigationServiceMock.Object);

            authenticationViewModel.Email    = "*****@*****.**";
            authenticationViewModel.Password = "******";
            authenticationViewModel.ApiKey   = "ApiKey";

            // Act
            authenticationViewModel.LoginAsync();

            // Assert
            Assert.True(string.IsNullOrEmpty(authenticationViewModel.Message));
            Assert.False(string.IsNullOrEmpty(authenticationViewModel.Password));
            Assert.False(string.IsNullOrEmpty(authenticationViewModel.ApiKey));
            Assert.False(string.IsNullOrEmpty(authenticationViewModel.Email));
        }