Skip to content

Commit

Permalink
Added more Pester tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelinux committed Mar 21, 2024
1 parent d9c18ba commit 93526e1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Src/Private/Get-DiaHtmlTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Function Get-DiaHTMLTable {
Takes an array and converts it to a HTML table used for GraphViz Node label
.Example
$SiteSubnets = @("192.68.5.0/24", "192.68.7.0/24", "10.0.0.0/24")
Get-DiaHTMLTable -Rows $DCs -Align "Center" -ColumnSize 2 -MultiColunms
Get-DiaHTMLTable -Rows $SiteSubnets -Align "Center" -ColumnSize 2 -MultiColunms
_________________________________
| | |
|192.168.5.0/24 |192.168.7.0/24 |
Expand All @@ -16,7 +16,7 @@ Function Get-DiaHTMLTable {
_________________________________
$SiteSubnets = @("192.68.5.0/24", "192.68.7.0/24", "10.0.0.0/24")
Get-DiaHTMLTable -Rows $DCs -Align "Center"
Get-DiaHTMLTable -Rows $SiteSubnets -Align "Center"
_________________
| |
|192.168.5.0/24 |
Expand All @@ -43,7 +43,7 @@ Function Get-DiaHTMLTable {
The table cell border
.PARAMETER FontSize
The text fornt size used inside the cell
.PARAMETER IconType
.PARAMETER Logo
Icon used to draw the node type
.PARAMETER ColumnSize
This number is used to specified how to split the object inside the HTML table.
Expand Down
2 changes: 2 additions & 0 deletions Src/Private/Get-DiaNodeIcon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Function Get-DiaNodeIcon {
Object used to specified aditional node information
.PARAMETER IconType
Icon used to draw the node type
.PARAMETER ImagesObj
Hashtable with the IconName > IconPath translation
#>

[CmdletBinding()]
Expand Down
22 changes: 22 additions & 0 deletions Tests/Get-DiaHTMLTable.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
BeforeAll {
$Images = @{
"Main_Logo" = "Diagrammer.png"
"ForestRoot" = "RootDomain.png"
}
$SiteSubnets = @("192.68.5.0/24", "192.68.7.0/24", "10.0.0.0/24")
$HTMLMultiColumn = Get-DiaHTMLTable -Rows $SiteSubnets -Align "Center" -ColumnSize 2 -MultiColunms
$HTMLSingleColumn = Get-DiaHTMLTable -Rows $SiteSubnets -Align "Center"
$HTMLSingleColumnIcon = Get-DiaHTMLTable -Rows $SiteSubnets -Align "Center" -Logo "ForestRoot" -ImagesObj $Images
}

Describe "Get-DiaHTMLTable" {
It "Returns a single column HMLT table" {
$HTMLSingleColumn | Should -BeExactly '<TABLE STYLE="ROUNDED" border="0" cellborder="0" cellpadding="5"><TR><TD valign="top" align="Center" colspan="2"><B><FONT POINT-SIZE="14">192.68.5.0/24</FONT></B></TD></TR><TR><TD valign="top" align="Center" colspan="2"><B><FONT POINT-SIZE="14">192.68.7.0/24</FONT></B></TD></TR><TR><TD valign="top" align="Center" colspan="2"><B><FONT POINT-SIZE="14">10.0.0.0/24</FONT></B></TD></TR></TABLE>'
}
It "Returns a multi column HMLT table" {
$HTMLMultiColumn | Should -BeExactly '<TABLE border="0" cellborder="0" cellpadding="5"><TR><TD align="Center" colspan="1"><FONT POINT-SIZE="14">192.68.5.0/24</FONT></TD><TD align="Center" colspan="1"><FONT POINT-SIZE="14">192.68.7.0/24</FONT></TD></TR><TR><TD align="Center" colspan="1"><FONT POINT-SIZE="14">10.0.0.0/24</FONT></TD></TR></TABLE>'
}
It "Returns a multi column HMLT table with single Icon" {
$HTMLSingleColumnIcon | Should -BeExactly '<TABLE STYLE="ROUNDED" border="0" cellborder="0" cellpadding="5"><TR><TD fixedsize="true" width="80" height="80" ALIGN="Center" colspan="1" rowspan="4"><img src="RootDomain.png"/></TD></TR><TR><TD valign="top" align="Center" colspan="2"><B><FONT POINT-SIZE="14">192.68.5.0/24</FONT></B></TD></TR><TR><TD valign="top" align="Center" colspan="2"><B><FONT POINT-SIZE="14">192.68.7.0/24</FONT></B></TD></TR><TR><TD valign="top" align="Center" colspan="2"><B><FONT POINT-SIZE="14">10.0.0.0/24</FONT></B></TD></TR></TABLE>'
}
}
13 changes: 13 additions & 0 deletions Tests/Get-DiaImagePercent.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
BeforeAll {
$Logo = Join-Path $TestsFolder "Logo.png"
$ImgProperties = Get-DiaImagePercent -ImageInput $Logo
}

Describe "Get-DiaImagePercent" {
It "Returns image Height" {
$ImgProperties.Height | Should -Be 225
}
It "Returns image Width" {
$ImgProperties.Width | Should -Be 225
}
}
28 changes: 28 additions & 0 deletions Tests/Get-DiaNodeIcon.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BeforeAll {
$Images = @{
"Main_Logo" = "Diagrammer.png"
"ForestRoot" = "RootDomain.png"
}
$DC = "Server-DC-01v"
$DCRows = @{
Memory = "4GB"
CPU = "2"
}
$HTMLOutPut = Get-DiaNodeIcon -Name $DC -IconType "ForestRoot" -Align "Center" -Rows $DCRows -ImagesObj $Images
$HTMLOutPutDebug = Get-DiaNodeIcon -Name $DC -IconType "ForestRoot" -Align "Center" -Rows $DCRows -ImagesObj $Images -IconDebug $true
}

Describe "Get-DiaNodeIcon" {
It "Returns a HMLT table" {
$HTMLOutPut | Should -BeExactly "<TABLE border='0' cellborder='0' cellspacing='5' cellpadding='0'><TR><TD ALIGN='Center' colspan='1'><img src='RootDomain.png'/></TD></TR><TR><TD align='Center'><B>Server-DC-01v</B></TD></TR><TR><TD align='Center' colspan='1'><FONT POINT-SIZE='14'>Memory: 4GB</FONT></TD></TR> <TR><TD align='Center' colspan='1'><FONT POINT-SIZE='14'>CPU: 2</FONT></TD></TR></TABLE>"
}
It "Returns a HMLT table with the IMG tag" {
$HTMLOutPut | Should -Match "<img src='RootDomain.png'/>"
}
It "Returns a HMLT table with red colored table" {
$HTMLOutPutDebug | Should -Match "color='red'"
}
It "Returns a HMLT table without the IMG tag" {
$HTMLOutPutDebug | Should -Not -Match "<img src='RootDomain.png'/>"
}
}

0 comments on commit 93526e1

Please sign in to comment.