Represents a definition for a flag what can be set to a user or channel.
Flag definitions are not hardcoded in the IrcShark.Chatting.Irc library. Following the internet draft IRC RPL_ISUPPORT Numeric Definition (draft-brocklesby-irc-isupport-03) written by E. Brocklesby the server can define custom flags. This class represents one of this definitions made by the server. See IrcShark.Chatting.Irc.IrcStandardDefinition for more information about the ISUPPORT reply.
Exemple #1
0
 public void Constructor3()
 {
     FlagDefinition fd = new FlagDefinition('f', ModeArt.User, FlagParameter.None, FlagParameter.Optional);
     Assert.IsNotNull(fd);
     Assert.AreEqual(FlagParameter.None, fd.SetParameter);
     Assert.AreEqual(FlagParameter.Optional, fd.UnsetParameter);
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Required, FlagParameter.None);
     Assert.AreEqual(FlagParameter.Required, fd.SetParameter);
     Assert.AreEqual(FlagParameter.None, fd.UnsetParameter);
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Optional, FlagParameter.Required);
     Assert.AreEqual(FlagParameter.Optional, fd.SetParameter);
     Assert.AreEqual(FlagParameter.Required, fd.UnsetParameter);
 }
Exemple #2
0
 public void Constructor()
 {
     FlagDefinition flag1 = new FlagDefinition('m', ModeArt.Channel);
     FlagDefinition flag2 = new FlagDefinition('v', ModeArt.Channel, FlagParameter.Required);
     Mode mode = new Mode(flag1, FlagArt.Unset);
     Assert.NotNull(mode);
     Assert.AreEqual(FlagArt.Unset, mode.Art);
     Assert.AreEqual(mode.Flag, flag1);
     Assert.IsNull(mode.Parameter);
     mode = new Mode(flag2, FlagArt.Set, "nick");
     Assert.NotNull(mode);
     Assert.AreEqual(FlagArt.Set, mode.Art);
     Assert.AreEqual(mode.Flag, flag2);
     Assert.AreEqual(mode.Parameter, "nick");
 }
Exemple #3
0
 public void Constructor1()
 {
     FlagDefinition fd = new FlagDefinition('f', ModeArt.User);
     Assert.IsNotNull(fd);
     Assert.AreEqual(ModeArt.User, fd.AppliesTo);
     Assert.AreEqual('f', fd.Character);
     fd = new FlagDefinition('g', ModeArt.Channel);
     Assert.AreEqual(ModeArt.Channel, fd.AppliesTo);
     Assert.AreEqual('g', fd.Character);
     fd = new FlagDefinition('h', ModeArt.Channel);
     Assert.AreEqual(ModeArt.Channel, fd.AppliesTo);
     Assert.AreEqual('h', fd.Character);
     fd = new FlagDefinition('i', ModeArt.User);
     Assert.AreEqual(ModeArt.User, fd.AppliesTo);
     Assert.AreEqual('i', fd.Character);
 }
Exemple #4
0
 public void Constructor2()
 {
     FlagDefinition fd = new FlagDefinition('f', ModeArt.User, FlagParameter.None);
     Assert.IsNotNull(fd);
     Assert.AreEqual(ModeArt.User, fd.AppliesTo);
     Assert.AreEqual('f', fd.Character);
     Assert.AreEqual(FlagParameter.None, fd.SetParameter);
     Assert.AreEqual(FlagParameter.None, fd.UnsetParameter);
     fd = new FlagDefinition('i', ModeArt.Channel, FlagParameter.Required);
     Assert.AreEqual(ModeArt.Channel, fd.AppliesTo);
     Assert.AreEqual('i', fd.Character);
     Assert.AreEqual(FlagParameter.Required, fd.SetParameter);
     Assert.AreEqual(FlagParameter.Required, fd.UnsetParameter);
     fd = new FlagDefinition('i', ModeArt.User, FlagParameter.Optional);
     Assert.AreEqual(ModeArt.User, fd.AppliesTo);
     Assert.AreEqual('i', fd.Character);
     Assert.AreEqual(FlagParameter.Optional, fd.SetParameter);
     Assert.AreEqual(FlagParameter.Optional, fd.UnsetParameter);
 }
Exemple #5
0
 public void IsParameter()
 {
     FlagDefinition fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Required);
     Assert.IsTrue(fd.IsParameter(FlagArt.Set, "any text here"));
     Assert.IsTrue(fd.IsParameter(FlagArt.Unset, "any other text here"));
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Optional);
     Assert.IsTrue(fd.IsParameter(FlagArt.Set, "any text here"));
     Assert.IsTrue(fd.IsParameter(FlagArt.Unset, "any other text here"));
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.None);
     Assert.IsFalse(fd.IsParameter(FlagArt.Set, "bla"));
     Assert.IsFalse(fd.IsParameter(FlagArt.Unset, "foo"));
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Required, FlagParameter.None);
     Assert.IsTrue(fd.IsParameter(FlagArt.Set, "bar"));
     Assert.IsFalse(fd.IsParameter(FlagArt.Unset, "blubb"));
 }
Exemple #6
0
 public void NeedsParameter()
 {
     FlagDefinition fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Required);
     Assert.IsTrue(fd.NeedsParameter(FlagArt.Set));
     Assert.IsTrue(fd.NeedsParameter(FlagArt.Unset));
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Optional);
     Assert.IsFalse(fd.NeedsParameter(FlagArt.Set));
     Assert.IsFalse(fd.NeedsParameter(FlagArt.Unset));
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.None);
     Assert.IsFalse(fd.NeedsParameter(FlagArt.Set));
     Assert.IsFalse(fd.NeedsParameter(FlagArt.Unset));
     fd = new FlagDefinition('f', ModeArt.User, FlagParameter.Required, FlagParameter.Optional);
     Assert.IsTrue(fd.NeedsParameter(FlagArt.Set));
     Assert.IsFalse(fd.NeedsParameter(FlagArt.Unset));
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the Mode class.
 /// </summary>
 /// <param name="flag">The flag, what is changed.</param>
 /// <param name="art">The way, the flag is changed.</param>
 /// <param name="parameter">The parameter for the flag.</param>
 public Mode(FlagDefinition flag, FlagArt art, string parameter)
 {
     this.flag = flag;
     this.art = art;
     this.parameter = parameter;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the Mode class.
 /// </summary>
 /// <param name="flag">The flag, what is changed.</param>
 /// <param name="art">The way, the flag is changed.</param>
 public Mode(FlagDefinition flag, FlagArt art)
 {
     this.flag = flag;
     this.art = art;
 }