public void PropertyTest() { var r = new StringRules(_minLength, _maxLength, CharType.AlphaLower); Assert.AreEqual(_minLength, r.MinLength); Assert.AreEqual(_maxLength, r.MaxLength); Assert.AreEqual(CharType.AlphaLower, r.AllowedChars); }
public void AlphaUpperTest() { var r = new StringRules(_minLength, _maxLength, CharType.AlphaUpper); Assert.IsFalse(r.IsValid(_sLower)); Assert.IsTrue(r.IsValid(_sUpper)); Assert.IsFalse(r.IsValid(_sUpperLower)); Assert.IsFalse(r.IsValid(_sNumeric)); Assert.IsFalse(r.IsValid(_sPunctuation)); Assert.IsFalse(r.IsValid(_sSentence)); Assert.IsFalse(r.IsValid(_sWhitespace)); }
public void StringTooShortTest() { var r = new StringRules(_maxLength, _maxLength, CharType.Alpha | CharType.Punctuation | CharType.Whitespace); Assert.IsFalse(r.IsValid(_sLower)); Assert.IsFalse(r.IsValid(_sUpper)); Assert.IsFalse(r.IsValid(_sUpperLower)); Assert.IsFalse(r.IsValid(_sNumeric)); Assert.IsFalse(r.IsValid(_sPunctuation)); Assert.IsFalse(r.IsValid(_sSentence)); Assert.IsFalse(r.IsValid(_sWhitespace)); }
public void SetUpEngineSettings() { EngineSettings.Initialize(new EngineSettings(new Vector2(0f, 0.0009f), new Vector2(0.5f, 0.5f))); ShopSettings.Initialize(new ShopSettings(6 * 6)); StatusEffectsSettings.Initialize(new StatusEffectsSettings(500)); GroupSettings.Initialize(new GroupSettings(10, 1000 * 60, (x, y) => true)); QuestSettings.Initialize(new QuestSettings(20)); GameTimeSettings.Initialize(new GameTimeSettings(19, 6, -0.5f, 50, new DateTime(2010, 1, 1), 1000f)); PeerTradingSettings.Initialize(new PeerTradingSettings(20, 128)); var rankNames = new string[] { "Recruit", "Member", "VIP", "Founder" }; var nameRules = new StringRules(3, 50, CharType.All); var tagRules = new StringRules(1, 4, CharType.All); var maxRank = (GuildRank)(rankNames.Length - 1); GuildSettings.Initialize(new GuildSettings(1000 * 60, maxRank, rankNames, nameRules, tagRules, 3, 2, 1, 1, 2, 2)); }
/// <summary> /// Initializes the <see cref="EngineSettingsInitializer"/> class. /// </summary> static EngineSettingsInitializer() { Initialize(new EngineSettingsInitializer()); ShopSettings.Initialize(new ShopSettings(6 * 6)); StatusEffectsSettings.Initialize(new StatusEffectsSettings(500)); GroupSettings.Initialize(new GroupSettings(10, 1000 * 60, CanJoinGroupHandler)); QuestSettings.Initialize(new QuestSettings(20)); GameTimeSettings.Initialize(new GameTimeSettings(19, 6, -0.5f, 50, new DateTime(2010, 1, 1), 1000f)); PeerTradingSettings.Initialize(new PeerTradingSettings(GameData.MaxInventorySize, 128)); var rankNames = new string[] { "Recruit", "Member", "VIP", "Founder" }; var nameRules = new StringRules(3, 50, CharType.All); var tagRules = new StringRules(1, 4, CharType.All); var maxRank = (GuildRank)(rankNames.Length - 1); GuildSettings.Initialize(new GuildSettings(1000 * 60, maxRank, rankNames, nameRules, tagRules, 3, 2, 1, 1, 2, 2)); }
/// <summary> /// Initializes a new instance of the <see cref="GuildSettings"/> class. /// </summary> /// <exception cref="ArgumentNullException"><paramref name="rankNames" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="nameRules" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="tagRules" /> is <c>null</c>.</exception> /// <exception cref="ArgumentException">There must be exactly one rank name for each rank.</exception> /// <exception cref="ArgumentException">Guild rank names may not be empty or null.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>inviteResponseTime</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankRename</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankViewLog</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankKick</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankInvite</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankPromote</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankDemote</c> is out of range.</exception> public GuildSettings(int inviteResponseTime, GuildRank highestRank, string[] rankNames, StringRules nameRules, StringRules tagRules, GuildRank minRankRename, GuildRank minRankViewLog, GuildRank minRankKick, GuildRank minRankInvite, GuildRank minRankPromote, GuildRank minRankDemote) { if (rankNames == null) throw new ArgumentNullException("rankNames"); if (rankNames.Length != highestRank + 1) throw new ArgumentException("There must be exactly one rank name for each rank.", "rankNames"); if (rankNames.Any(x => string.IsNullOrEmpty(x))) throw new ArgumentException("Guild rank names may not be empty or null.", "rankNames"); if (nameRules == null) throw new ArgumentNullException("nameRules"); if (tagRules == null) throw new ArgumentNullException("tagRules"); if (inviteResponseTime <= 0) throw new ArgumentOutOfRangeException("inviteResponseTime"); if (minRankRename > highestRank) throw new ArgumentOutOfRangeException("minRankRename"); if (minRankViewLog > highestRank) throw new ArgumentOutOfRangeException("minRankViewLog"); if (minRankKick > highestRank) throw new ArgumentOutOfRangeException("minRankKick"); if (minRankInvite > highestRank) throw new ArgumentOutOfRangeException("minRankInvite"); if (minRankPromote > highestRank) throw new ArgumentOutOfRangeException("minRankPromote"); if (minRankDemote > highestRank) throw new ArgumentOutOfRangeException("minRankDemote"); _inviteResponseTime = inviteResponseTime; _highestRank = highestRank; _rankNames = rankNames; _nameRules = nameRules; _tagRules = tagRules; _minRankRename = minRankRename; _minRankViewLog = minRankViewLog; _minRankKick = minRankKick; _minRankInvite = minRankInvite; _minRankPromote = minRankPromote; _minRankDemote = minRankDemote; }
public void EmptyInputTest() { var r = new StringRules(_minLength, _maxLength, CharType.All); Assert.IsFalse(r.IsValid(string.Empty)); }
public void NullInputTest() { var r = new StringRules(_minLength, _maxLength, CharType.All); Assert.IsFalse(r.IsValid(null)); }
/// <summary> /// Initializes a new instance of the <see cref="GuildSettings"/> class. /// </summary> /// <exception cref="ArgumentNullException"><paramref name="rankNames" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="nameRules" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="tagRules" /> is <c>null</c>.</exception> /// <exception cref="ArgumentException">There must be exactly one rank name for each rank.</exception> /// <exception cref="ArgumentException">Guild rank names may not be empty or null.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>inviteResponseTime</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankRename</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankViewLog</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankKick</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankInvite</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankPromote</c> is out of range.</exception> /// <exception cref="ArgumentOutOfRangeException"><c>minRankDemote</c> is out of range.</exception> public GuildSettings(int inviteResponseTime, GuildRank highestRank, string[] rankNames, StringRules nameRules, StringRules tagRules, GuildRank minRankRename, GuildRank minRankViewLog, GuildRank minRankKick, GuildRank minRankInvite, GuildRank minRankPromote, GuildRank minRankDemote) { if (rankNames == null) { throw new ArgumentNullException("rankNames"); } if (rankNames.Length != highestRank + 1) { throw new ArgumentException("There must be exactly one rank name for each rank.", "rankNames"); } if (rankNames.Any(x => string.IsNullOrEmpty(x))) { throw new ArgumentException("Guild rank names may not be empty or null.", "rankNames"); } if (nameRules == null) { throw new ArgumentNullException("nameRules"); } if (tagRules == null) { throw new ArgumentNullException("tagRules"); } if (inviteResponseTime <= 0) { throw new ArgumentOutOfRangeException("inviteResponseTime"); } if (minRankRename > highestRank) { throw new ArgumentOutOfRangeException("minRankRename"); } if (minRankViewLog > highestRank) { throw new ArgumentOutOfRangeException("minRankViewLog"); } if (minRankKick > highestRank) { throw new ArgumentOutOfRangeException("minRankKick"); } if (minRankInvite > highestRank) { throw new ArgumentOutOfRangeException("minRankInvite"); } if (minRankPromote > highestRank) { throw new ArgumentOutOfRangeException("minRankPromote"); } if (minRankDemote > highestRank) { throw new ArgumentOutOfRangeException("minRankDemote"); } _inviteResponseTime = inviteResponseTime; _highestRank = highestRank; _rankNames = rankNames; _nameRules = nameRules; _tagRules = tagRules; _minRankRename = minRankRename; _minRankViewLog = minRankViewLog; _minRankKick = minRankKick; _minRankInvite = minRankInvite; _minRankPromote = minRankPromote; _minRankDemote = minRankDemote; }