Skip to content

Commit

Permalink
Tidied up the code post merge
Browse files Browse the repository at this point in the history
  • Loading branch information
deanhume committed Apr 19, 2016
1 parent b6a72d8 commit 2beb6b1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion HtmlMinifier.Tests/FileExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace HtmlMinifier.Tests
public class FileExtensionTests
{
[Test]
public void GithubIssue25__ShouldReturnCorrectly()
public void GithubIssue25_ShouldReturnCorrectly()
{
Assert.That("test.html".IsHtmlFile(), Is.True);
Assert.That("codes.js.aspx".IsHtmlFile(), Is.True);
Expand Down
15 changes: 8 additions & 7 deletions HtmlMinifier.Tests/MinificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void MinifyContents_WithLanguageSpecficCharacters_ShouldReturnCorrectly()
}

[Test]
public void GithubIssue10__ShouldReturnCorrectly()
public void GithubIssue10_ShouldReturnCorrectly()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/10
// Arrange
Expand All @@ -81,7 +81,7 @@ public void GithubIssue10__ShouldReturnCorrectly()
}

[Test]
public void GithubIssue13__ShouldReturnCorrectly()
public void GithubIssue13_ShouldReturnCorrectly()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/13
string expectedResult = DataHelpers.GithubIssue13Result;
Expand All @@ -94,7 +94,7 @@ public void GithubIssue13__ShouldReturnCorrectly()
}

[Test]
public void SixtyFiveKCharacters__ShouldBreakToNextLine()
public void SixtyFiveKCharacters_ShouldBreakToNextLine()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/14
List<string> args = new List<string> {"pathToFiles", "60000"};
Expand All @@ -109,7 +109,7 @@ public void SixtyFiveKCharacters__ShouldBreakToNextLine()
}

[Test]
public void SixtyFiveKCharacters__WithoutArgs_ShouldMakeNoChange()
public void SixtyFiveKCharacters_WithoutArgs_ShouldMakeNoChange()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/14
List<string> args = new List<string> { "pathToFiles" };
Expand Down Expand Up @@ -150,7 +150,7 @@ public void RemoveMultipleJavaScriptComments_WithStandardText_ShouldReturnCorrec
}

[Test]
public void GithubIssue19Inherits__ShouldReturnCorrectly()
public void GithubIssue19Inherits_ShouldReturnCorrectly()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/19
string expectedResult = DataHelpers.GithubIssue19InheritsResult;
Expand All @@ -163,7 +163,7 @@ public void GithubIssue19Inherits__ShouldReturnCorrectly()
}

[Test]
public void GithubIssue19Multiple__ShouldReturnCorrectly()
public void GithubIssue19Multiple_ShouldReturnCorrectly()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/19
string expectedResult = DataHelpers.GithubIssue19MultipleResult;
Expand All @@ -176,10 +176,11 @@ public void GithubIssue19Multiple__ShouldReturnCorrectly()
}

[Test]
public void GithubIssue23__ShouldReturnCorrectly()
public void GithubIssue23_ShouldReturnCorrectly()
{
// A fix for a Github issue - https://github.com/deanhume/html-minifier/issues/23
string expectedResult = DataHelpers.GithubIssue23Result;

// test IgnoreHtmlComments
List<string> args = new List<string> { "ignorehtmlcomments" };

Expand Down
2 changes: 2 additions & 0 deletions ViewMinifier/Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ public Features(string[] args)
}

int maxLength = 0;

// This is a check to see if the args contain an optional parameter for the max line length
if (args != null && args.Length > 1)
{
// Try and parse the value sent through
int.TryParse(args[1], out maxLength);
}

MaxLength = maxLength;
}

Expand Down
1 change: 1 addition & 0 deletions ViewMinifier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static void Main(string[] args)
}
}
}

Console.WriteLine("Minification Complete");
}

Expand Down
14 changes: 14 additions & 0 deletions ViewMinifier/StreamReaderExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@ namespace HtmlMinifier
{
public static class StreamReaderExtension
{
/// <summary>
/// Minify the HTML code
/// </summary>
/// <param name="reader">The StreamReader.</param>
/// <param name="features">Any features to enable / disable.</param>
/// <returns>The minified HTML code.</returns>
public static string MinifyHtmlCode(this StreamReader reader, Features features)
{
return MinifyHtmlCode(reader.ReadToEnd(), features);
}

/// <summary>
/// Minifies the HTML code
/// </summary>
/// <param name="htmlCode">The HTML as a string</param>
/// <param name="features">Any features to enable / disable.</param>
/// <returns>The minified HTML code.</returns>
public static string MinifyHtmlCode(string htmlCode, Features features)
{
string contents;

// Minify the contents
contents = MinifyHtml(htmlCode, features);

Expand All @@ -23,6 +36,7 @@ public static string MinifyHtmlCode(string htmlCode, Features features)

// Re-add the @model declaration
contents = ReArrangeDeclarations(contents);

return contents;
}

Expand Down
7 changes: 7 additions & 0 deletions ViewMinifier/StringExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
{
public static class StringExtension
{
/// <summary>
/// Checks if a file extension matches
/// any given types for an ASP.net application
/// </summary>
/// <param name="value">The html file name.</param>
/// <returns>A boolean if the file is an html file.</returns>
public static bool IsHtmlFile(this string value)
{
var file = value.ToLower();

return file.EndsWith(".cshtml") ||
file.EndsWith(".vbhtml") ||
file.EndsWith(".aspx") ||
Expand Down

0 comments on commit 2beb6b1

Please sign in to comment.