/// <summary> /// Performs synchronization to the typed-in user's anime list on a button click (wired up via caliburn micro). /// </summary> /// <returns></returns> public async Task SyncUserAnimeList(string typedInUsername, MiruAppStatus appStatus, bool seasonSyncOn) { // get user's watching status anime list if (!await GetUserAnimeList()) { return; } // get current season if (seasonSyncOn) { if (!await GetCurrentSeason()) { return; } } // save user data to the db await SaveUserInfo(typedInUsername); // save api data to the database if (!await SaveAnimeListData(seasonSyncOn)) { return; } // update displayed username and sync date UpdateUiAfterDataSync(); }
public void UpdateAppStatus(MiruAppStatus newAppStatus, string detailedAppStatusDescription = null) { if (AppStatus != newAppStatus) { AppStatus = newAppStatus; } if (detailedAppStatusDescription != null) { AppStatusText = detailedAppStatusDescription; } }
// checks whether sync button should be enabled (wired up by caliburn micro) public bool CanSyncUserAnimeList(string typedInUsername, MiruAppStatus appStatus, bool syncSeasonList) { if (string.IsNullOrWhiteSpace(typedInUsername) || typedInUsername.Length < 2 || typedInUsername.Any(char.IsWhiteSpace) || typedInUsername.Length > 16 || (appStatus != MiruAppStatus.Idle && appStatus != MiruAppStatus.InternetConnectionProblems)) { return(false); } return(true); }
public void UpdateAppStatus_ShouldSetCorrectValues(MiruAppStatus inputAppStatus, string inputDetailedAppStatusDescription, MiruAppStatus expectedAppStatus, string expectedAppStatusText) { using (var mock = AutoMock.GetLoose()) { // Arrange var cls = mock.Create <ShellViewModel>(); // Act cls.UpdateAppStatus(inputAppStatus, inputDetailedAppStatusDescription); // Assert Assert.Equal(expectedAppStatus, cls.AppStatus); Assert.Equal(expectedAppStatusText, cls.AppStatusText); } }
public void CanSyncUserAnimeList_ShouldReturnCorrectValues(string typedInUsername, MiruAppStatus appStatus, bool expected) { using (var mock = AutoMock.GetLoose()) { // Arrange var cls = mock.Create <ShellViewModel>(); // Act bool actual = cls.CanSyncUserAnimeList(typedInUsername, appStatus, true); // Assert Assert.Equal(expected, actual); } }