1- using Microsoft . VisualStudio . TestTools . UnitTesting ;
2- using System ;
1+ using System ;
32using System . Collections . Generic ;
43using System . IO ;
54using System . Linq ;
5+ using Xunit ;
66
77namespace FileTypeInterrogator . Tests
88{
99 public partial class FileTypeInterrogatorTests
1010 {
11- [ TestMethod ]
11+ [ Fact ]
1212 public void CanDetectAscii ( )
1313 {
1414 const string extension = "ascii" ;
1515 DetectType ( extension , result =>
1616 {
17- Assert . IsNotNull ( result ) ;
18- Assert . IsTrue ( result . Name . StartsWith ( extension , StringComparison . OrdinalIgnoreCase ) ) ;
17+ Assert . NotNull ( result ) ;
18+ Assert . StartsWith ( extension , result . Name , StringComparison . OrdinalIgnoreCase ) ;
1919 } ) ;
2020 }
2121
22- [ TestMethod ]
22+ [ Fact ]
2323 public void CanDetectUTF8 ( )
2424 {
2525 const string extension = "utf8" ;
2626 DetectType ( extension , result =>
2727 {
28- Assert . IsNotNull ( result ) ;
29- Assert . IsTrue ( result . Name . StartsWith ( "UTF-8" , StringComparison . OrdinalIgnoreCase ) ) ;
30- Assert . IsTrue ( result . Name . IndexOf ( "BOM" , StringComparison . OrdinalIgnoreCase ) == - 1 ) ;
28+ Assert . NotNull ( result ) ;
29+ Assert . StartsWith ( "UTF-8" , result . Name , StringComparison . OrdinalIgnoreCase ) ;
30+ Assert . True ( result . Name . IndexOf ( "BOM" , StringComparison . OrdinalIgnoreCase ) == - 1 ) ;
3131 } ) ;
3232 }
3333
34- [ TestMethod ]
34+ [ Fact ]
3535 public void CanDetectUTF8BOM ( )
3636 {
3737 const string extension = "utf8bom" ;
3838 DetectType ( extension , result =>
3939 {
40- Assert . IsNotNull ( result ) ;
41- Assert . IsTrue ( result . Name . StartsWith ( "UTF-8" , StringComparison . OrdinalIgnoreCase ) ) ;
42- Assert . IsTrue ( result . Name . IndexOf ( "BOM" , StringComparison . OrdinalIgnoreCase ) > - 1 ) ;
40+ Assert . NotNull ( result ) ;
41+ Assert . StartsWith ( "UTF-8" , result . Name , StringComparison . OrdinalIgnoreCase ) ;
42+ Assert . True ( result . Name . IndexOf ( "BOM" , StringComparison . OrdinalIgnoreCase ) > - 1 ) ;
4343 } ) ;
4444 }
4545
46- [ DataTestMethod ]
47- [ DataRow ( "pdf" , DisplayName = "PDF Test ") ]
48- [ DataRow ( "fdf" , DisplayName = "FDF Test ") ]
46+ [ Theory ]
47+ [ InlineData ( "pdf" ) ]
48+ [ InlineData ( "fdf" ) ]
4949 public void CanDetectAdobe ( string extension )
5050 {
5151 DetectType ( extension ) ;
5252 }
5353
54- [ DataTestMethod ]
55- [ DataRow ( "ai" , DisplayName = "AI Test" ) ]
56- [ DataRow ( "bmp" , DisplayName = "BMP Test" ) ]
57- [ DataRow ( "gif" , DisplayName = "GIF Test" ) ]
58- [ DataRow ( "ico" , DisplayName = "ICO Test" ) ]
59- [ DataRow ( "jp2" , DisplayName = "JP2 Test" ) ]
60- [ DataRow ( "jpg" , DisplayName = "JPG Test" ) ]
61- [ DataRow ( "pcx" , DisplayName = "PCX Test" ) ]
62- [ DataRow ( "png" , DisplayName = "PNG Test" ) ]
63- [ DataRow ( "psd" , DisplayName = "PSD Test" ) ]
64- [ DataRow ( "tif" , DisplayName = "TIF Test" ) ]
65- [ DataRow ( "webp" , DisplayName = "WEBP Test" ) ]
54+ [ Theory ]
55+ [ InlineData ( "bmp" ) ]
56+ [ InlineData ( "gif" ) ]
57+ [ InlineData ( "ico" ) ]
58+ [ InlineData ( "jp2" ) ]
59+ [ InlineData ( "jpg" ) ]
60+ [ InlineData ( "pcx" ) ]
61+ [ InlineData ( "png" ) ]
62+ [ InlineData ( "psd" ) ]
63+ [ InlineData ( "tif" ) ]
64+ [ InlineData ( "webp" ) ]
6665 public void CanDetectImages ( string extension )
6766 {
6867 DetectType ( extension ) ;
6968 }
7069
71- [ DataTestMethod ]
72- [ DataRow ( "3gp" , DisplayName = "3GP Test ") ]
73- [ DataRow ( "avi" , DisplayName = "AVI Test ") ]
74- [ DataRow ( "flv" , DisplayName = "FLV Test ") ]
75- [ DataRow ( "mid" , DisplayName = "MID Test ") ]
76- [ DataRow ( "mkv" , DisplayName = "MKV Test ") ]
77- [ DataRow ( "mp4" , DisplayName = "MP4 Test ") ]
78- [ DataRow ( "webm" , DisplayName = "WEBM Test ") ]
79- [ DataRow ( "wmv" , DisplayName = "WMV Test ") ]
70+ [ Theory ]
71+ [ InlineData ( "3gp" ) ]
72+ [ InlineData ( "avi" ) ]
73+ [ InlineData ( "flv" ) ]
74+ [ InlineData ( "mid" ) ]
75+ [ InlineData ( "mkv" ) ]
76+ [ InlineData ( "mp4" ) ]
77+ [ InlineData ( "webm" ) ]
78+ [ InlineData ( "wmv" ) ]
8079 public void CanDetectVideo ( string extension )
8180 {
8281 DetectType ( extension ) ;
8382 }
8483
85- [ DataTestMethod ]
86- [ DataRow ( "ac3" , DisplayName = "AC3 Test ") ]
87- [ DataRow ( "aiff" , DisplayName = "AIFF Test ") ]
88- [ DataRow ( "flac" , DisplayName = "FLAC Test ") ]
89- [ DataRow ( "mp3" , DisplayName = "MP3 Test ") ]
90- [ DataRow ( "ogg" , DisplayName = "OGG Test ") ]
91- [ DataRow ( "ra" , DisplayName = "RA Test ") ]
92- [ DataRow ( "wav" , DisplayName = "WAV Test ") ]
84+ [ Theory ]
85+ [ InlineData ( "ac3" ) ]
86+ [ InlineData ( "aiff" ) ]
87+ [ InlineData ( "flac" ) ]
88+ [ InlineData ( "mp3" ) ]
89+ [ InlineData ( "ogg" ) ]
90+ [ InlineData ( "ra" ) ]
91+ [ InlineData ( "wav" ) ]
9392 public void CanDetectAudio ( string extension )
9493 {
9594 DetectType ( extension ) ;
9695 }
9796
98- [ DataTestMethod ]
99- [ DataRow ( "doc" , DisplayName = "DOC Test ") ]
100- [ DataRow ( "docx" , DisplayName = "DOC Test ") ]
101- [ DataRow ( "odp" , DisplayName = "ODP Test ") ]
102- [ DataRow ( "odt" , DisplayName = "ODT Test ") ]
103- [ DataRow ( "ppt" , DisplayName = "PPT Test ") ]
104- [ DataRow ( "pptx" , DisplayName = "PPTX Test ") ]
105- [ DataRow ( "rtf" , DisplayName = "RTF Test ") ]
106- [ DataRow ( "xls" , DisplayName = "XLS Test ") ]
107- [ DataRow ( "xlsx" , DisplayName = "XLSX Test ") ]
97+ [ Theory ]
98+ [ InlineData ( "doc" ) ]
99+ [ InlineData ( "docx" ) ]
100+ [ InlineData ( "odp" ) ]
101+ [ InlineData ( "odt" ) ]
102+ [ InlineData ( "ppt" ) ]
103+ [ InlineData ( "pptx" ) ]
104+ [ InlineData ( "rtf" ) ]
105+ [ InlineData ( "xls" ) ]
106+ [ InlineData ( "xlsx" ) ]
108107 public void CanDetectOffice ( string extension )
109108 {
110109 DetectType ( extension ) ;
111110 }
112111
113- [ DataTestMethod ]
114- [ DataRow ( "otf" , DisplayName = "OTF Test ") ]
115- [ DataRow ( "ttf" , DisplayName = "TTF Test ") ]
116- [ DataRow ( "woff" , DisplayName = "WOFF Test ") ]
112+ [ Theory ]
113+ [ InlineData ( "otf" ) ]
114+ [ InlineData ( "ttf" ) ]
115+ [ InlineData ( "woff" ) ]
117116 public void CanDetectFont ( string extension )
118117 {
119118 DetectType ( extension ) ;
120119 }
121120
122- [ DataTestMethod ]
123- [ DataRow ( "7z" , DisplayName = "7Z Test ") ]
124- [ DataRow ( "gz" , DisplayName = "GZ Test ") ]
125- [ DataRow ( "rar" , DisplayName = "RAR Test ") ]
126- [ DataRow ( "zip" , DisplayName = "ZIP Test ") ]
121+ [ Theory ]
122+ [ InlineData ( "7z" ) ]
123+ [ InlineData ( "gz" ) ]
124+ [ InlineData ( "rar" ) ]
125+ [ InlineData ( "zip" ) ]
127126 public void CanDetectCompressed ( string extension )
128127 {
129128 DetectType ( extension ) ;
130129 }
131130
132- [ DataTestMethod ]
133- [ DataRow ( "eml" , DisplayName = "EML Test ") ]
134- [ DataRow ( "vcf" , DisplayName = "VCF Test ") ]
131+ [ Theory ]
132+ [ InlineData ( "eml" ) ]
133+ [ InlineData ( "vcf" ) ]
135134 public void CanDetectOther ( string extension )
136135 {
137136 DetectType ( extension ) ;
@@ -141,12 +140,12 @@ private void DetectType(string extension)
141140 {
142141 DetectType ( extension , result =>
143142 {
144- Assert . IsNotNull ( result ) ;
145- Assert . IsTrue (
143+ Assert . NotNull ( result ) ;
144+ Assert . True (
146145 result . FileType . Equals ( extension , StringComparison . OrdinalIgnoreCase ) ||
147146 result . Alias ? . Any ( a => a . Equals ( extension , StringComparison . OrdinalIgnoreCase ) ) == true ,
148- "{0} and/or {1} do not equal {2}" ,
149- result . FileType , result . Alias ? . FirstOrDefault ( ) , extension ) ;
147+ string . Format ( "{0} and/or {1} do not equal {2}" ,
148+ result . FileType , result . Alias ? . FirstOrDefault ( ) , extension ) ) ;
150149 } ) ;
151150 }
152151
0 commit comments