public void TestDisposition(ContentDisposition disposition, int paramCount) { string fieldText = disposition.ToString(); MimeFieldParameters fieldParams = new MimeFieldParameters(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldText)); Assert.True(fieldParams.Count == paramCount); Assert.Equal(disposition.DispositionType, fieldParams[0].Value); Assert.Equal(disposition.FileName, fieldParams["filename"]); Assert.DoesNotThrow(() => Compare(fieldParams, disposition.Parameters)); string fieldTextSerialized = null; Assert.DoesNotThrow(() => fieldTextSerialized = fieldParams.Serialize()); fieldParams.Clear(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldTextSerialized)); Assert.True(fieldParams.Count == paramCount); Console.WriteLine(fieldTextSerialized); string alwaysfails = "attachment;size=123456789;xyz=\"pqr/?.<\";read-date=\"Thu, 10 Apr 2014 11:27:31 +0000\";filename=\"goobar.txt\";modification-date=\"Tue, 08 Apr 2014 11:27:31 +0000\";creation-date=\"Sat, 05 Apr 2014 11:27:31 +0000"; Assert.DoesNotThrow(() => new ContentDisposition(alwaysfails)); Assert.DoesNotThrow(() => new ContentDisposition(fieldTextSerialized)); }
public void TestContentType(ContentType contentType, int paramCount) { string fieldText = contentType.ToString(); MimeFieldParameters fieldParams = new MimeFieldParameters(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldText)); Assert.True(fieldParams.Count == paramCount); Assert.Equal(contentType.MediaType, fieldParams[0].Value); Assert.Equal <string>(contentType.Name, fieldParams["name"]); Assert.DoesNotThrow(() => Compare(fieldParams, contentType.Parameters)); string fieldTextSerialized = null; Assert.DoesNotThrow(() => fieldTextSerialized = fieldParams.Serialize()); fieldParams.Clear(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldTextSerialized)); Assert.True(fieldParams.Count == paramCount); Assert.DoesNotThrow(() => new ContentType(fieldTextSerialized)); }
public void TestDisposition(ContentDisposition disposition, int paramCount) { string fieldText = disposition.ToString(); MimeFieldParameters fieldParams = new MimeFieldParameters(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldText)); Assert.True(fieldParams.Count == paramCount); Assert.Equal(disposition.DispositionType, fieldParams[0].Value); Assert.Equal(disposition.FileName, fieldParams["filename"]); Assert.DoesNotThrow(() => Compare(fieldParams, disposition.Parameters)); string fieldTextSerialized = null; Assert.DoesNotThrow(() => fieldTextSerialized = fieldParams.Serialize()); fieldParams.Clear(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldTextSerialized)); Assert.True(fieldParams.Count == paramCount); Assert.DoesNotThrow(() => new ContentDisposition(fieldTextSerialized)); }
public void TestContentType(ContentType contentType, int paramCount) { string fieldText = contentType.ToString(); MimeFieldParameters fieldParams = new MimeFieldParameters(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldText)); Assert.True(fieldParams.Count == paramCount); Assert.Equal(contentType.MediaType, fieldParams[0].Value); Assert.Equal<string>(contentType.Name, fieldParams["name"]); Assert.DoesNotThrow(() => Compare(fieldParams, contentType.Parameters)); string fieldTextSerialized = null; Assert.DoesNotThrow(() => fieldTextSerialized = fieldParams.Serialize()); fieldParams.Clear(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldTextSerialized)); Assert.True(fieldParams.Count == paramCount); Assert.DoesNotThrow(() => new ContentType(fieldTextSerialized)); }
public void TestDisposition(ContentDisposition disposition, int paramCount) { string fieldText = disposition.ToString(); MimeFieldParameters fieldParams = new MimeFieldParameters(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldText)); Assert.True(fieldParams.Count == paramCount); Assert.Equal(disposition.DispositionType, fieldParams[0].Value); Assert.Equal(disposition.FileName, fieldParams["filename"]); Assert.DoesNotThrow(() => Compare(fieldParams, disposition.Parameters)); string fieldTextSerialized = null; Assert.DoesNotThrow(() => fieldTextSerialized = fieldParams.Serialize()); fieldParams.Clear(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldTextSerialized)); Assert.True(fieldParams.Count == paramCount); Assert.DoesNotThrow(() => new ContentDisposition(fieldTextSerialized)); }
public void TestDisposition(ContentDisposition disposition, int paramCount) { string fieldText = disposition.ToString(); MimeFieldParameters fieldParams = new MimeFieldParameters(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldText)); Assert.True(fieldParams.Count == paramCount); Assert.Equal(disposition.DispositionType, fieldParams[0].Value); Assert.Equal(disposition.FileName, fieldParams["filename"]); Assert.DoesNotThrow(() => Compare(fieldParams, disposition.Parameters)); string fieldTextSerialized = null; Assert.DoesNotThrow(() => fieldTextSerialized = fieldParams.Serialize()); fieldParams.Clear(); Assert.DoesNotThrow(() => fieldParams.Deserialize(fieldTextSerialized)); Assert.True(fieldParams.Count == paramCount); Console.WriteLine(fieldTextSerialized); string alwaysfails = "attachment;size=123456789;xyz=\"pqr/?.<\";read-date=\"Thu, 10 Apr 2014 11:27:31 +0000\";filename=\"goobar.txt\";modification-date=\"Tue, 08 Apr 2014 11:27:31 +0000\";creation-date=\"Sat, 05 Apr 2014 11:27:31 +0000"; Assert.DoesNotThrow(() => new ContentDisposition(alwaysfails)); Assert.DoesNotThrow(() => new ContentDisposition(fieldTextSerialized)); }