Skip to content

Commit 9005f81

Browse files
authored
Merge pull request #8 from ghost1face/updates
v2.0.0 Release
2 parents 4a655a8 + d9a2a03 commit 9005f81

File tree

10 files changed

+141
-147
lines changed

10 files changed

+141
-147
lines changed

.github/workflows/dotnet-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
contents: read
1414

1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
1717
- name: Setup .NET
18-
uses: actions/setup-dotnet@v1
18+
uses: actions/setup-dotnet@v4
1919
with:
20-
dotnet-version: '6.0.x' # SDK Version to use.
20+
dotnet-version: '9.0.x' # SDK Version to use.
2121
- name: Build
2222
working-directory: ./src
2323
run: dotnet build --configuration Release .

.github/workflows/dotnet.yml

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,15 @@ jobs:
1313
steps:
1414
- name: Clean
1515
run: rm -rf *.*
16-
- uses: actions/checkout@v2
17-
- name: Setup .NET 6
18-
uses: actions/setup-dotnet@v1
16+
- uses: actions/checkout@v4
17+
- name: Setup .NET 9
18+
uses: actions/setup-dotnet@v4
1919
with:
20-
dotnet-version: '6.0.x'
21-
- name: Setup .NET 5
22-
uses: actions/setup-dotnet@v1
20+
dotnet-version: '9.0.x'
21+
- name: Setup .NET 8
22+
uses: actions/setup-dotnet@v4
2323
with:
24-
dotnet-version: '5.0.x'
25-
- name: Setup .NET Core 3.1
26-
uses: actions/setup-dotnet@v1
27-
with:
28-
dotnet-version: '3.1.x'
29-
- name: Setup .NET Core 2.1
30-
uses: actions/setup-dotnet@v1
31-
with:
32-
dotnet-version: '2.1.x'
24+
dotnet-version: '8.0.x'
3325
- name: Restore dependencies
3426
working-directory: ./src
3527
run: dotnet restore
@@ -38,4 +30,4 @@ jobs:
3830
run: dotnet build --no-restore --configuration Release
3931
- name: Test
4032
working-directory: ./src
41-
run: dotnet test --no-build --verbosity normal --configuration Release
33+
run: dotnet test --no-build --verbosity normal --configuration Release

src/FileTypeInterrogator.Tests/FileTypeInterrogator.Tests.csproj

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="coverlet.collector" Version="1.2.0">
9+
<PackageReference Include="coverlet.collector" Version="6.0.4">
10+
<PrivateAssets>all</PrivateAssets>
11+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12+
</PackageReference>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
14+
<PackageReference Include="xunit" Version="2.9.3" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1016
<PrivateAssets>all</PrivateAssets>
1117
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1218
</PackageReference>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
14-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
15-
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
1619
</ItemGroup>
1720

1821
<ItemGroup>

src/FileTypeInterrogator.Tests/FileTypeInterrogatorTests.cs

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,137 +1,136 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.IO;
54
using System.Linq;
5+
using Xunit;
66

77
namespace 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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,48 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
2-
using System.IO;
1+
using System.IO;
2+
using Xunit;
33

44
namespace FileTypeInterrogator.Tests
55
{
6-
[TestClass]
76
public partial class FileTypeInterrogatorTests
87
{
98
private IFileTypeInterrogator fileTypeInterrogator;
109

11-
[TestInitialize]
12-
public void Init()
10+
public FileTypeInterrogatorTests()
1311
{
1412
fileTypeInterrogator = new FileTypeInterrogator();
1513
}
1614

17-
[TestMethod]
15+
[Fact]
1816
public void CanDetectAlias_Jpg()
1917
{
2018
var filePath = GetFileByType("jpg");
2119
var fileContents = File.ReadAllBytes(filePath);
2220

2321
var result = fileTypeInterrogator.IsType(fileContents, "jpg");
2422

25-
Assert.IsTrue(result);
23+
Assert.True(result);
2624
}
2725

28-
[TestMethod]
26+
[Fact]
2927
public void CanDetectAlias_Jpeg()
3028
{
3129
var filePath = GetFileByType("jpg");
3230
var fileContents = File.ReadAllBytes(filePath);
3331

3432
var result = fileTypeInterrogator.IsType(fileContents, "jpeg");
3533

36-
Assert.IsTrue(result);
34+
Assert.True(result);
3735
}
3836

39-
[TestMethod]
37+
[Fact]
4038
public void CanDetectJpg_By_MimeType()
4139
{
4240
var filePath = GetFileByType("jpg");
4341
var fileContents = File.ReadAllBytes(filePath);
4442

4543
var result = fileTypeInterrogator.IsType(fileContents, "image/jpeg");
4644

47-
Assert.IsTrue(result);
45+
Assert.True(result);
4846
}
4947
}
5048
}

src/FileTypeInterrogator.sln

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.421
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.1.32210.238
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FileTypeInterrogator", "FileTypeInterrogator\FileTypeInterrogator.csproj", "{E5333901-A30A-45D0-B787-BC2F58208F9F}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileTypeInterrogator.Tests", "FileTypeInterrogator.Tests\FileTypeInterrogator.Tests.csproj", "{8181D724-8886-4541-8819-9FF208A28074}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FileTypeInterrogator.Tests", "FileTypeInterrogator.Tests\FileTypeInterrogator.Tests.csproj", "{8181D724-8886-4541-8819-9FF208A28074}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{42DC82B3-A307-4945-AC5C-D0A6D527F942}"
11+
ProjectSection(SolutionItems) = preProject
12+
..\.editorconfig = ..\.editorconfig
13+
..\.gitattributes = ..\.gitattributes
14+
..\.gitignore = ..\.gitignore
15+
..\LICENSE.md = ..\LICENSE.md
16+
..\README.md = ..\README.md
17+
EndProjectSection
918
EndProject
1019
Global
1120
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)