Esempio n. 1
0
        /// <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();
        }
Esempio n. 2
0
 public void UpdateAppStatus(MiruAppStatus newAppStatus, string detailedAppStatusDescription = null)
 {
     if (AppStatus != newAppStatus)
     {
         AppStatus = newAppStatus;
     }
     if (detailedAppStatusDescription != null)
     {
         AppStatusText = detailedAppStatusDescription;
     }
 }
Esempio n. 3
0
 // 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);
 }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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);
            }
        }