-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for FileInfo.CountLines()
- Loading branch information
1 parent
d4c4653
commit 88be53d
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Description: C# Extension Methods Library to enhances the .NET Framework by adding hundreds of new methods. It drastically increases developers productivity and code readability. Support C# and VB.NET | ||
// Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods | ||
// Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues | ||
// License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE | ||
// More projects: http://www.zzzprojects.com/ | ||
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved. | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Z.IO.Test | ||
{ | ||
[TestClass] | ||
public class System_IO_FileInfo_CountLines | ||
{ | ||
[TestMethod] | ||
public void CountLines() | ||
{ | ||
// Type | ||
var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_ReadAllLines.txt")); | ||
|
||
// Intialization | ||
using (FileStream stream = @this.Create()) | ||
{ | ||
byte[] byteToWrites = Encoding.Default.GetBytes("Fizz" + Environment.NewLine + "Buzz" + Environment.NewLine + "Fizz2"); | ||
stream.Write(byteToWrites, 0, byteToWrites.Length); | ||
} | ||
|
||
// Examples | ||
var result1 = @this.CountLines(); // return 3; | ||
var result2 = @this.CountLines(x => !x.Contains("Buzz")); // return 2; | ||
|
||
// Unit Test | ||
Assert.AreEqual(3, result1); | ||
Assert.AreEqual(2, result2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters