File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ // 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
2
+ // Website & Documentation: https://github.com/zzzprojects/Z.ExtensionMethods
3
+ // Forum: https://github.com/zzzprojects/Z.ExtensionMethods/issues
4
+ // License: https://github.com/zzzprojects/Z.ExtensionMethods/blob/master/LICENSE
5
+ // More projects: http://www.zzzprojects.com/
6
+ // Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7
+ using System ;
8
+ using System . Collections . Generic ;
9
+ using System . IO ;
10
+ using System . Linq ;
11
+ using System . Text ;
12
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
13
+
14
+ namespace Z . IO . Test
15
+ {
16
+ [ TestClass ]
17
+ public class System_IO_FileInfo_CountLines
18
+ {
19
+ [ TestMethod ]
20
+ public void CountLines ( )
21
+ {
22
+ // Type
23
+ var @this = new FileInfo ( Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "Examples_System_IO_FileInfo_ReadAllLines.txt" ) ) ;
24
+
25
+ // Intialization
26
+ using ( FileStream stream = @this . Create ( ) )
27
+ {
28
+ byte [ ] byteToWrites = Encoding . Default . GetBytes ( "Fizz" + Environment . NewLine + "Buzz" + Environment . NewLine + "Fizz2" ) ;
29
+ stream . Write ( byteToWrites , 0 , byteToWrites . Length ) ;
30
+ }
31
+
32
+ // Examples
33
+ var result1 = @this . CountLines ( ) ; // return 3;
34
+ var result2 = @this . CountLines ( x => ! x . Contains ( "Buzz" ) ) ; // return 2;
35
+
36
+ // Unit Test
37
+ Assert . AreEqual ( 3 , result1 ) ;
38
+ Assert . AreEqual ( 2 , result2 ) ;
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change 86
86
<Compile Include =" System.IO.FileInfo\FileInfo.GetDirectoryFullName.cs" />
87
87
<Compile Include =" System.IO.FileInfo\FileInfo.GetDirectoryName.cs" />
88
88
<Compile Include =" System.IO.FileInfo\FileInfo.GetFileNameWithoutExtension.cs" />
89
+ <Compile Include =" System.IO.FileInfo\FileInfo.CountLines.cs" />
89
90
<Compile Include =" System.IO.FileInfo\FileInfo.GetPathRoot.cs" />
90
91
<Compile Include =" System.IO.FileInfo\FileInfo.HasExtension.cs" />
91
92
<Compile Include =" System.IO.FileInfo\FileInfo.IsPathRooted.cs" />
You can’t perform that action at this time.
0 commit comments