public void TicksPropertyAcccess_GetProperty_Returns_Correct_String(string propertyName)
        {
            //Arrange
            var ticksPropertyAccess = new TicksPropertyAccess();
            var accessingUser = new UserInfo();

            long expected = DateTime.MinValue.Ticks;
            switch (propertyName)
            {
                case "now":
                    expected = DateTime.Now.Ticks;
                    break;
                case "today":
                    expected = DateTime.Today.Ticks;
                    break;
                case "ticksperday":
                    expected = TimeSpan.TicksPerDay;
                    break;
            }

            //Act
            bool propertyNotFound = false;
            string propertyValue = ticksPropertyAccess.GetProperty(propertyName, "", CultureInfo.InvariantCulture,
                                                                   accessingUser, Scope.DefaultSettings, ref propertyNotFound);

            //Assert
            Assert.AreEqual(expected.ToString(CultureInfo.InvariantCulture), propertyValue);
        }
예제 #2
0
 /// <summary>
 /// creates a new TokenReplace object for custom context
 /// </summary>
 /// <param name="AccessLevel">Security level granted by the calling object</param>
 /// <param name="Language">Locale to be used for formatting etc.</param>
 /// <param name="PortalSettings">PortalSettings to be used</param>
 /// <param name="User">user, for which the properties shall be returned</param>
 /// <param name="ModuleID">ID of the current module</param>
 /// <history>
 ///     08/10/2007    sleupold  documented
 ///     10/19/2007    sleupold  ModuleID added
 /// </history>
 public TokenReplace(Scope AccessLevel, string Language, PortalSettings PortalSettings, UserInfo User, int ModuleID)
 {
     CurrentAccessLevel = AccessLevel;
     if (AccessLevel != Scope.NoSettings)
     {
         if (PortalSettings == null)
         {
             if (HttpContext.Current != null)
             {
                 this.PortalSettings = PortalController.GetCurrentPortalSettings();
             }
         }
         else
         {
             this.PortalSettings = PortalSettings;
         }
         if (User == null)
         {
             if (HttpContext.Current != null)
             {
                 this.User = (UserInfo)HttpContext.Current.Items["UserInfo"];
             }
             else
             {
                 this.User = new UserInfo();
             }
             AccessingUser = this.User;
         }
         else
         {
             this.User = User;
             if (HttpContext.Current != null)
             {
                 AccessingUser = (UserInfo)HttpContext.Current.Items["UserInfo"];
             }
             else
             {
                 AccessingUser = new UserInfo();
             }
         }
         if (string.IsNullOrEmpty(Language))
         {
             this.Language = new Localization.Localization().CurrentUICulture;
         }
         else
         {
             this.Language = Language;
         }
         if (ModuleID != Null.NullInteger)
         {
             ModuleId = ModuleID;
         }
     }
     PropertySource["date"]     = new DateTimePropertyAccess();
     PropertySource["datetime"] = new DateTimePropertyAccess();
     PropertySource["ticks"]    = new TicksPropertyAccess();
     PropertySource["culture"]  = new CulturePropertyAccess();
 }
예제 #3
0
 /// <summary>
 /// creates a new TokenReplace object for custom context
 /// </summary>
 /// <param name="accessLevel">Security level granted by the calling object</param>
 /// <param name="language">Locale to be used for formatting etc.</param>
 /// <param name="portalSettings">PortalSettings to be used</param>
 /// <param name="user">user, for which the properties shall be returned</param>
 /// <param name="moduleID">ID of the current module</param>
 public TokenReplace(Scope accessLevel, string language, PortalSettings portalSettings, UserInfo user, int moduleID)
 {
     ModuleId           = int.MinValue;
     CurrentAccessLevel = accessLevel;
     if (accessLevel != Scope.NoSettings)
     {
         if (portalSettings == null)
         {
             if (HttpContext.Current != null)
             {
                 PortalSettings = PortalController.Instance.GetCurrentPortalSettings();
             }
         }
         else
         {
             PortalSettings = portalSettings;
         }
         if (user == null)
         {
             if (HttpContext.Current != null)
             {
                 User = (UserInfo)HttpContext.Current.Items["UserInfo"];
             }
             else
             {
                 User = new UserInfo();
             }
             AccessingUser = User;
         }
         else
         {
             User = user;
             if (HttpContext.Current != null)
             {
                 AccessingUser = (UserInfo)HttpContext.Current.Items["UserInfo"];
             }
             else
             {
                 AccessingUser = new UserInfo();
             }
         }
         Language = string.IsNullOrEmpty(language) ? new Localization.Localization().CurrentUICulture : language;
         if (moduleID != Null.NullInteger)
         {
             ModuleId = moduleID;
         }
     }
     PropertySource["date"]     = new DateTimePropertyAccess();
     PropertySource["datetime"] = new DateTimePropertyAccess();
     PropertySource["ticks"]    = new TicksPropertyAccess();
     PropertySource["culture"]  = new CulturePropertyAccess();
 }
        public void TicksPropertyAcccess_GetProperty_Sets_PropertyNotFound(string propertyName, bool expected)
        {
            //Arrange
            var ticksPropertyAccess = new TicksPropertyAccess();
            var accessingUser = new UserInfo();

            //Act
            bool propertyNotFound = false;
            string propertyValue = ticksPropertyAccess.GetProperty(propertyName, "", CultureInfo.InvariantCulture,
                                                                   accessingUser, Scope.DefaultSettings, ref propertyNotFound);

            //Assert
            Assert.AreEqual(expected, propertyNotFound);
        }
 /// <summary>
 /// creates a new TokenReplace object for custom context
 /// </summary>
 /// <param name="AccessLevel">Security level granted by the calling object</param>
 /// <param name="Language">Locale to be used for formatting etc.</param>
 /// <param name="PortalSettings">PortalSettings to be used</param>
 /// <param name="User">user, for which the properties shall be returned</param>
 /// <param name="ModuleID">ID of the current module</param>
 /// <history>
 ///     08/10/2007    sleupold  documented
 ///     10/19/2007    sleupold  ModuleID added
 /// </history>
 public TokenReplace(Scope AccessLevel, string Language, PortalSettings PortalSettings, UserInfo User, int ModuleID)
 {
     CurrentAccessLevel = AccessLevel;
     if (AccessLevel != Scope.NoSettings) {
         if (PortalSettings == null) {
             if (HttpContext.Current != null) {
                 this.PortalSettings = PortalController.GetCurrentPortalSettings();
             }
         } else {
             this.PortalSettings = PortalSettings;
         }
         if (User == null) {
             if (HttpContext.Current != null) {
                 this.User = (UserInfo)HttpContext.Current.Items["UserInfo"];
             } else {
                 this.User = new UserInfo();
             }
             AccessingUser = this.User;
         } else {
             this.User = User;
             if (HttpContext.Current != null) {
                 AccessingUser = (UserInfo)HttpContext.Current.Items["UserInfo"];
             } else {
                 AccessingUser = new UserInfo();
             }
         }
         if (string.IsNullOrEmpty(Language)) {
             this.Language = new Localization.Localization().CurrentUICulture;
         } else {
             this.Language = Language;
         }
         if (ModuleID != Null.NullInteger) {
             ModuleId = ModuleID;
         }
     }
     PropertySource["date"] = new DateTimePropertyAccess();
     PropertySource["datetime"] = new DateTimePropertyAccess();
     PropertySource["ticks"] = new TicksPropertyAccess();
     PropertySource["culture"] = new CulturePropertyAccess();
 }