Merge pull request #97 from RockyTV/caps

Fix some bugs
This commit is contained in:
Drew DeVault 2018-03-06 10:26:22 -05:00 committed by GitHub
commit c2a9c53ac8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View File

@ -24,7 +24,7 @@ namespace ChatSharp.Handlers
}
// TODO: Consider doing this differently
// TODO: Allow users to specify other things to handle
if (value != null)
if (!string.IsNullOrEmpty(value))
{
switch (key.ToUpper())
{

View File

@ -52,7 +52,8 @@ namespace ChatSharp
foreach (string rawTag in rawTags.Split(';'))
{
var replacedTag = rawTag.Replace(@"\:", ";");
KeyValuePair<string, string> tag = new KeyValuePair<string, string>(replacedTag, string.Empty);
// The spec declares `@a=` as a tag with an empty value, while `@b;` as a tag with a null value
KeyValuePair<string, string> tag = new KeyValuePair<string, string>(replacedTag, null);
if (replacedTag.Contains("="))
{

View File

@ -28,7 +28,7 @@ namespace ChatSharp
if (!compatibility)
{
DateTime parsedDate;
if (!DateTime.TryParseExact(date, @"yyyy-MM-dd\THH:mm:ss.fff\Z", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out parsedDate))
if (!DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out parsedDate))
throw new ArgumentException("The date string was provided in an invalid format.", date);
Date = parsedDate;

View File

@ -82,6 +82,18 @@ namespace ChatSharp.Tests
CollectionAssert.AreEqual(fromMessage.Tags, compareTags);
}
[TestMethod]
public void NewValidMessage_TagsNoValue()
{
IrcMessage fromMessage = new IrcMessage("@a=;b :nick!ident@host.com PRIVMSG me :Hello");
KeyValuePair<string, string>[] compareTags = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("a", ""),
new KeyValuePair<string, string>("b", null),
};
CollectionAssert.AreEqual(fromMessage.Tags, compareTags);
}
[TestMethod]
public void Timestamp_CompareISOString()
{