public void GetLastSettingsSaveTime_LastSettingsDontExists_ReturnNull()
        {
            using (ShimsContext.Create())
            {
                ShimFilePath();
                IUserContext userContext;
                DateTime?    lastSettingsSaveTime;

                // Arrange
                userContext = GetTestUserContext();

                // Act
                MySettingsManager.DeleteLastSettingsFile(userContext);
                lastSettingsSaveTime = MySettingsManager.GetLastSettingsSaveTime(userContext);

                // Assert
                Assert.IsNull(lastSettingsSaveTime);
            }
        }
        // This test expects that it can write to "C:\Temp\myTempFile.txt"
        public void GetLastSettingsSaveTime_LastSettingsExists_ReturnDateTimeNow()
        {
            using (ShimsContext.Create())
            {
                ShimFilePath();
                IUserContext userContext;
                AnalysisPortal.MySettings.MySettings mySettings;
                DateTime?lastSettingsSaveTime;

                // Arrange
                userContext = GetTestUserContext();
                mySettings  = CreateMySettingsObjectWithTaxonFilter(1, 2, 5);

                // Act
                MySettingsManager.SaveLastSettings(userContext, mySettings);
                lastSettingsSaveTime = MySettingsManager.GetLastSettingsSaveTime(userContext);
                TimeSpan timeSpan = DateTime.Now - lastSettingsSaveTime.Value;

                // Assert
                Assert.IsTrue(timeSpan.TotalMilliseconds < 1000);
            }
        }
        /// <summary>
        /// Creates a MySettingsButtonGroupViewModel.
        /// </summary>
        /// <returns></returns>
        public MySettingsButtonGroupViewModel CreateMySettingsButtonGroupViewModel()
        {
            var  model                       = new MySettingsButtonGroupViewModel();
            bool isAnySettingsMade           = MySettings.HasSettings;
            bool isUserLoggedIn              = UserContext.IsAuthenticated();
            bool doesSettingsFileExistOnDisk = false;

            if (isUserLoggedIn)
            {
                doesSettingsFileExistOnDisk = MySettingsManager.DoesNameExistOnDisk(UserContext, MySettingsManager.SettingsName);
            }

            if (isAnySettingsMade && isUserLoggedIn)
            {
                model.IsSaveButtonEnabled = true;
            }

            if (isUserLoggedIn && doesSettingsFileExistOnDisk)
            {
                model.IsLoadButtonEnabled = true;
            }

            if (isAnySettingsMade)
            {
                model.IsResetButtonEnabled = true;
            }
            if (isUserLoggedIn)
            {
                model.LastSettingsSaveTime = MySettingsManager.GetLastSettingsSaveTime(UserContext);
                if (model.LastSettingsSaveTime.HasValue)
                {
                    model.DoesLastSettingsExists = true;
                }
            }

            return(model);
        }