Exemple #1
0
        public RedirectResult LoadAutoSavedSettings(string returnUrl, string userName)
        {
            if (SessionHandler.UserContext != null)
            {
                SessionHandler.MySettings = MySettingsManager.LoadLastSettings(SessionHandler.UserContext);
                SessionHandler.UserMessages.Add(new UserMessage(Resource.SharedAutosavedSettingsLoaded, UserMessageType.Info));
            }
            else if (userName != null)
            {
                HttpCookie httpCookie = Request.Cookies["ASP.NET_SessionId"];
                if (httpCookie != null)
                {
                    string sessionId = httpCookie.Value;
                    if (LastUserSessionIdManager.IsLastUserSessionIdOk(userName, sessionId))
                    {
                        SessionHandler.MySettings = MySettingsManager.LoadLastSettings(userName);
                    }
                }
            }

            return(Redirect(returnUrl.ToLower()));
        }
        // This test expects that it can write to "C:\Temp\myTempFile.txt"
        public void SaveAndGetLastUsedSettings_CreateMySettingsWithTaxa_LastSettingsSavedToFileAndReturnedOnLoad()
        {
            using (ShimsContext.Create())
            {
                ShimFilePath();

                IUserContext userContext;
                AnalysisPortal.MySettings.MySettings mySettings;
                AnalysisPortal.MySettings.MySettings loadedSettings;

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

                // Act
                MySettingsManager.SaveLastSettings(userContext, mySettings);
                loadedSettings = MySettingsManager.LoadLastSettings(userContext);

                // Assert
                CollectionAssert.AreEqual(new List <int> {
                    1, 2, 5
                }, loadedSettings.Filter.Taxa.TaxonIds);
            }
        }
        // This test expects that it can write to "C:\Temp\myTempFile.txt"
        public void SaveLastSettings_SaveTwoTimes_LastSavedSettingsIsOverwritten()
        {
            using (ShimsContext.Create())
            {
                ShimFilePath();
                IUserContext userContext;
                AnalysisPortal.MySettings.MySettings mySettings;
                AnalysisPortal.MySettings.MySettings loadedSettings;

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

                // Act
                MySettingsManager.SaveLastSettings(userContext, mySettings);
                loadedSettings = MySettingsManager.LoadLastSettings(userContext);

                // Assert
                CollectionAssert.AreEqual(new List <int> {
                    1, 2, 5
                }, loadedSettings.Filter.Taxa.TaxonIds);


                // Arrange
                mySettings = CreateMySettingsObjectWithTaxonFilter(10, 12, 22);

                // Act
                MySettingsManager.SaveLastSettings(userContext, mySettings);
                loadedSettings = MySettingsManager.LoadLastSettings(userContext);

                // Assert
                CollectionAssert.AreEqual(new List <int> {
                    10, 12, 22
                }, loadedSettings.Filter.Taxa.TaxonIds);
            }
        }