Skip to content

Commit f18ccec

Browse files
author
Kapil Borle
committed
Add tests for EditableText class
1 parent a1ec516 commit f18ccec

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Tests/Engine/EditableText.tests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,38 @@ function foo {
104104
$result = $editableText.ApplyEdit($edit)
105105
$result.ToString() | Should Be $expected
106106
}
107+
108+
It "Should return a read-only collection of lines in the text" {
109+
$def = @'
110+
function foo {
111+
param(
112+
[bool] $param1
113+
)
114+
}
115+
'@
116+
$text = New-Object `
117+
-TypeName "Microsoft.Windows.PowerShell.ScriptAnalyzer.EditableText" `
118+
-ArgumentList @($def)
119+
120+
{$text.Lines.Add("abc")} | Should Throw
121+
}
122+
123+
It "Should return the correct number of lines in the text" {
124+
$def = @'
125+
function foo
126+
{
127+
get-childitem
128+
$x=1+2
129+
$hashtable = @{
130+
property1 = "value"
131+
anotherProperty = "another value"
132+
}
133+
}
134+
'@
135+
$text = New-Object `
136+
-TypeName "Microsoft.Windows.PowerShell.ScriptAnalyzer.EditableText" `
137+
-ArgumentList @($def)
138+
$text.LineCount | Should Be 9
139+
}
107140
}
108141
}

0 commit comments

Comments
 (0)