// 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(); } }
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)); }
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)); }
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)); }
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)); }